Package com.google.gerrit.server.project
Class ProjectConfig
- java.lang.Object
-
- com.google.gerrit.server.git.meta.VersionedMetaData
-
- com.google.gerrit.server.project.ProjectConfig
-
- All Implemented Interfaces:
ValidationError.Sink
public class ProjectConfig extends VersionedMetaData implements ValidationError.Sink
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ProjectConfig.Factory
-
Nested classes/interfaces inherited from class com.google.gerrit.server.git.meta.VersionedMetaData
VersionedMetaData.BatchMetaDataUpdate, VersionedMetaData.PathInfo
-
-
Field Summary
Fields Modifier and Type Field Description static String
ACCESS
static String
COMMENTLINK
static String
KEY_ALLOW_POST_SUBMIT
static String
KEY_BRANCH
static String
KEY_CAN_OVERRIDE
static String
KEY_COPY_CONDITION
static String
KEY_DEFAULT_VALUE
static String
KEY_ENABLED
static String
KEY_FUNCTION
static String
KEY_IGNORE_SELF_APPROVAL
static String
KEY_LABEL_DESCRIPTION
static String
KEY_LINK
static String
KEY_MATCH
static String
KEY_PREFIX
static String
KEY_SR_APPLICABILITY_EXPRESSION
static String
KEY_SR_DESCRIPTION
static String
KEY_SR_OVERRIDE_EXPRESSION
static String
KEY_SR_OVERRIDE_IN_CHILD_PROJECTS
static String
KEY_SR_SUBMITTABILITY_EXPRESSION
static String
KEY_SUFFIX
static String
KEY_TEXT
static String
KEY_VALUE
static String
LABEL
static String
PROJECT_CONFIG
static com.google.common.collect.ImmutableSet<String>
SR_KEYS
static String
SUBMIT_REQUIREMENT
-
Fields inherited from class com.google.gerrit.server.git.meta.VersionedMetaData
inserter, newTree, projectName, reader, revision, rw
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCommentLinkSection(StoredCommentLinkInfo commentLink)
void
addSubscribeSection(SubscribeSection s)
static StoredCommentLinkInfo
buildCommentLink(org.eclipse.jgit.lib.Config cfg, String name, boolean allowRaw)
void
clearSubmitRequirements()
void
error(ValidationError error)
AccessSection
getAccessSection(String name)
Returns an access section,name
typically is a ref pattern.Collection<AccessSection>
getAccessSections()
AccountsSection
getAccountsSection()
BranchOrderSection
getBranchOrderSection()
CachedProjectConfig
getCacheable()
Returns an immutable, thread-safe representation of this object that can be cached.boolean
getCheckReceivedObjects()
Returns the checkReceivedObjects for this project, default is true.Collection<StoredCommentLinkInfo>
getCommentLinkSections()
ContributorAgreement
getContributorAgreement(String name)
Collection<ContributorAgreement>
getContributorAgreements()
GroupReference
getGroup(AccountGroup.UUID uuid)
Returns the group reference, if the group is used by at least one rule.GroupReference
getGroup(String groupName)
Returns the group reference corresponding to the specified group name if the group is used by at least one rule or plugin value.Map<String,LabelType>
getLabelSections()
long
getMaxObjectSizeLimit()
Returns the maxObjectSizeLimit configured on this project, or zero if not configured.ConfiguredMimeTypes
getMimeTypes()
Project.NameKey
getName()
Collection<NotifyConfig>
getNotifyConfigs()
PluginConfig
getPluginConfig(String pluginName)
Project
getProject()
protected String
getRefName()
Returns name of the reference storing this configuration.org.eclipse.jgit.lib.ObjectId
getRulesId()
Returns the project's rules.pl ObjectId, if present in the branch.Map<String,SubmitRequirement>
getSubmitRequirementSections()
Map<Project.NameKey,SubscribeSection>
getSubscribeSections()
List<ValidationError>
getValidationErrors()
Get the validation errors, if any were discovered during load.boolean
hasLegacyPermissions()
void
load(org.eclipse.jgit.lib.Repository repo)
void
load(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.lib.ObjectId revision)
void
load(org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.lib.ObjectId revision)
protected void
onLoad()
Set up the metadata, parsing any state from the loaded revision.protected boolean
onSave(org.eclipse.jgit.lib.CommitBuilder commit)
Save any changes to the metadata in a commit.void
putNotifyConfig(String name, NotifyConfig nc)
void
remove(AccessSection section)
void
remove(AccessSection section, Permission permission)
void
remove(AccessSection section, Permission permission, PermissionRule rule)
void
removeCommentLinkSection(String name)
void
renameGroup(AccountGroup.UUID uuid, String newName)
void
replace(ContributorAgreement section)
GroupReference
resolve(GroupReference group)
void
setAccountsSection(AccountsSection accountsSection)
void
setBranchOrderSection(BranchOrderSection branchOrderSection)
void
setProject(Project.Builder project)
boolean
updateGroupNames(GroupBackend groupBackend)
Check all GroupReferences use current group name, repairing stale ones.void
updateLabelType(String name, Consumer<LabelType.Builder> update)
Allows a mutation of an existingLabelType
.void
updatePluginConfig(String pluginName, Consumer<PluginConfig.Update> pluginConfigUpdate)
void
updateProject(Consumer<Project.Builder> update)
void
upsertAccessSection(String name, Consumer<AccessSection.Builder> update)
void
upsertContributorAgreement(ContributorAgreement ca)
Adds or replaces the givenContributorAgreement
in this config.void
upsertLabelType(LabelType labelType)
Adds or replaces the givenLabelType
in this config.void
upsertSubmitRequirement(SubmitRequirement requirement)
Adds or replaces the givenSubmitRequirement
in this config.static String
validMaxObjectSizeLimit(String value)
-
Methods inherited from class com.google.gerrit.server.git.meta.VersionedMetaData
commit, commit, commitToNewRef, getObjectId, getPathInfos, getRevision, load, load, load, load, load, openUpdate, openUpdate, readConfig, readConfig, readFile, readTree, readUTF8, saveConfig, saveFile, saveUTF8, set, set, set
-
-
-
-
Field Detail
-
COMMENTLINK
public static final String COMMENTLINK
- See Also:
- Constant Field Values
-
LABEL
public static final String LABEL
- See Also:
- Constant Field Values
-
KEY_LABEL_DESCRIPTION
public static final String KEY_LABEL_DESCRIPTION
- See Also:
- Constant Field Values
-
KEY_FUNCTION
public static final String KEY_FUNCTION
- See Also:
- Constant Field Values
-
KEY_DEFAULT_VALUE
public static final String KEY_DEFAULT_VALUE
- See Also:
- Constant Field Values
-
KEY_ALLOW_POST_SUBMIT
public static final String KEY_ALLOW_POST_SUBMIT
- See Also:
- Constant Field Values
-
KEY_IGNORE_SELF_APPROVAL
public static final String KEY_IGNORE_SELF_APPROVAL
- See Also:
- Constant Field Values
-
KEY_COPY_CONDITION
public static final String KEY_COPY_CONDITION
- See Also:
- Constant Field Values
-
KEY_VALUE
public static final String KEY_VALUE
- See Also:
- Constant Field Values
-
KEY_CAN_OVERRIDE
public static final String KEY_CAN_OVERRIDE
- See Also:
- Constant Field Values
-
KEY_BRANCH
public static final String KEY_BRANCH
- See Also:
- Constant Field Values
-
SUBMIT_REQUIREMENT
public static final String SUBMIT_REQUIREMENT
- See Also:
- Constant Field Values
-
KEY_SR_DESCRIPTION
public static final String KEY_SR_DESCRIPTION
- See Also:
- Constant Field Values
-
KEY_SR_APPLICABILITY_EXPRESSION
public static final String KEY_SR_APPLICABILITY_EXPRESSION
- See Also:
- Constant Field Values
-
KEY_SR_SUBMITTABILITY_EXPRESSION
public static final String KEY_SR_SUBMITTABILITY_EXPRESSION
- See Also:
- Constant Field Values
-
KEY_SR_OVERRIDE_EXPRESSION
public static final String KEY_SR_OVERRIDE_EXPRESSION
- See Also:
- Constant Field Values
-
KEY_SR_OVERRIDE_IN_CHILD_PROJECTS
public static final String KEY_SR_OVERRIDE_IN_CHILD_PROJECTS
- See Also:
- Constant Field Values
-
SR_KEYS
public static final com.google.common.collect.ImmutableSet<String> SR_KEYS
-
KEY_MATCH
public static final String KEY_MATCH
- See Also:
- Constant Field Values
-
KEY_LINK
public static final String KEY_LINK
- See Also:
- Constant Field Values
-
KEY_PREFIX
public static final String KEY_PREFIX
- See Also:
- Constant Field Values
-
KEY_SUFFIX
public static final String KEY_SUFFIX
- See Also:
- Constant Field Values
-
KEY_TEXT
public static final String KEY_TEXT
- See Also:
- Constant Field Values
-
KEY_ENABLED
public static final String KEY_ENABLED
- See Also:
- Constant Field Values
-
PROJECT_CONFIG
public static final String PROJECT_CONFIG
- See Also:
- Constant Field Values
-
ACCESS
public static final String ACCESS
- See Also:
- Constant Field Values
-
-
Method Detail
-
getCacheable
public CachedProjectConfig getCacheable()
Returns an immutable, thread-safe representation of this object that can be cached.
-
buildCommentLink
public static StoredCommentLinkInfo buildCommentLink(org.eclipse.jgit.lib.Config cfg, String name, boolean allowRaw) throws IllegalArgumentException
- Throws:
IllegalArgumentException
-
addCommentLinkSection
public void addCommentLinkSection(StoredCommentLinkInfo commentLink)
-
removeCommentLinkSection
public void removeCommentLinkSection(String name)
-
load
public void load(org.eclipse.jgit.lib.Repository repo) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException
- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
load
public void load(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.lib.ObjectId revision) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException
- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
load
public void load(org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.lib.ObjectId revision) throws IOException, org.eclipse.jgit.errors.ConfigInvalidException
- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
getName
public Project.NameKey getName()
-
getProject
public Project getProject()
-
setProject
public void setProject(Project.Builder project)
-
updateProject
public void updateProject(Consumer<Project.Builder> update)
-
getAccountsSection
public AccountsSection getAccountsSection()
-
setAccountsSection
public void setAccountsSection(AccountsSection accountsSection)
-
getAccessSection
public AccessSection getAccessSection(String name)
Returns an access section,name
typically is a ref pattern.
-
upsertAccessSection
public void upsertAccessSection(String name, Consumer<AccessSection.Builder> update)
-
getAccessSections
public Collection<AccessSection> getAccessSections()
-
getBranchOrderSection
public BranchOrderSection getBranchOrderSection()
-
setBranchOrderSection
public void setBranchOrderSection(BranchOrderSection branchOrderSection)
-
getSubscribeSections
public Map<Project.NameKey,SubscribeSection> getSubscribeSections()
-
addSubscribeSection
public void addSubscribeSection(SubscribeSection s)
-
remove
public void remove(AccessSection section)
-
remove
public void remove(AccessSection section, Permission permission)
-
remove
public void remove(AccessSection section, Permission permission, PermissionRule rule)
-
getContributorAgreement
public ContributorAgreement getContributorAgreement(String name)
-
getContributorAgreements
public Collection<ContributorAgreement> getContributorAgreements()
-
replace
public void replace(ContributorAgreement section)
-
getNotifyConfigs
public Collection<NotifyConfig> getNotifyConfigs()
-
putNotifyConfig
public void putNotifyConfig(String name, NotifyConfig nc)
-
getSubmitRequirementSections
public Map<String,SubmitRequirement> getSubmitRequirementSections()
-
upsertSubmitRequirement
public void upsertSubmitRequirement(SubmitRequirement requirement)
Adds or replaces the givenSubmitRequirement
in this config.
-
clearSubmitRequirements
public void clearSubmitRequirements()
-
upsertLabelType
public void upsertLabelType(LabelType labelType)
Adds or replaces the givenLabelType
in this config.
-
updateLabelType
public void updateLabelType(String name, Consumer<LabelType.Builder> update)
Allows a mutation of an existingLabelType
.
-
upsertContributorAgreement
public void upsertContributorAgreement(ContributorAgreement ca)
Adds or replaces the givenContributorAgreement
in this config.
-
getCommentLinkSections
public Collection<StoredCommentLinkInfo> getCommentLinkSections()
-
getMimeTypes
public ConfiguredMimeTypes getMimeTypes()
-
resolve
public GroupReference resolve(GroupReference group)
-
renameGroup
public void renameGroup(AccountGroup.UUID uuid, String newName)
-
getGroup
public GroupReference getGroup(AccountGroup.UUID uuid)
Returns the group reference, if the group is used by at least one rule.
-
getGroup
public GroupReference getGroup(String groupName)
Returns the group reference corresponding to the specified group name if the group is used by at least one rule or plugin value.
-
getRulesId
public org.eclipse.jgit.lib.ObjectId getRulesId()
Returns the project's rules.pl ObjectId, if present in the branch. Null if it doesn't exist.
-
getMaxObjectSizeLimit
public long getMaxObjectSizeLimit()
Returns the maxObjectSizeLimit configured on this project, or zero if not configured.
-
getCheckReceivedObjects
public boolean getCheckReceivedObjects()
Returns the checkReceivedObjects for this project, default is true.
-
updateGroupNames
public boolean updateGroupNames(GroupBackend groupBackend)
Check all GroupReferences use current group name, repairing stale ones.- Parameters:
groupBackend
- cache to use when looking up group information by UUID.- Returns:
- true if one or more group names was stale.
-
getValidationErrors
public List<ValidationError> getValidationErrors()
Get the validation errors, if any were discovered during load.- Returns:
- list of errors; empty list if there are no errors.
-
getRefName
protected String getRefName()
Description copied from class:VersionedMetaData
Returns name of the reference storing this configuration.- Specified by:
getRefName
in classVersionedMetaData
-
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 classVersionedMetaData
- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
updatePluginConfig
public void updatePluginConfig(String pluginName, Consumer<PluginConfig.Update> pluginConfigUpdate)
-
getPluginConfig
public PluginConfig getPluginConfig(String pluginName)
-
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 classVersionedMetaData
- Returns:
- true if the commit should proceed, false to abort.
- Throws:
IOException
org.eclipse.jgit.errors.ConfigInvalidException
-
validMaxObjectSizeLimit
public static String validMaxObjectSizeLimit(String value) throws org.eclipse.jgit.errors.ConfigInvalidException
- Throws:
org.eclipse.jgit.errors.ConfigInvalidException
-
error
public void error(ValidationError error)
- Specified by:
error
in interfaceValidationError.Sink
-
hasLegacyPermissions
public boolean hasLegacyPermissions()
-
-