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 classProjectConfig.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 StringACCESSstatic StringCOMMENTLINKstatic StringKEY_ALLOW_POST_SUBMITstatic StringKEY_BRANCHstatic StringKEY_CAN_OVERRIDEstatic StringKEY_COPY_CONDITIONstatic StringKEY_DEFAULT_VALUEstatic StringKEY_ENABLEDstatic StringKEY_FUNCTIONstatic StringKEY_IGNORE_SELF_APPROVALstatic StringKEY_LABEL_DESCRIPTIONstatic StringKEY_LINKstatic StringKEY_MATCHstatic StringKEY_PREFIXstatic StringKEY_SR_APPLICABILITY_EXPRESSIONstatic StringKEY_SR_DESCRIPTIONstatic StringKEY_SR_OVERRIDE_EXPRESSIONstatic StringKEY_SR_OVERRIDE_IN_CHILD_PROJECTSstatic StringKEY_SR_SUBMITTABILITY_EXPRESSIONstatic StringKEY_SUFFIXstatic StringKEY_TEXTstatic StringKEY_VALUEstatic StringLABELstatic StringPROJECT_CONFIGstatic com.google.common.collect.ImmutableSet<String>SR_KEYSstatic StringSUBMIT_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 voidaddCommentLinkSection(StoredCommentLinkInfo commentLink)voidaddSubscribeSection(SubscribeSection s)static StoredCommentLinkInfobuildCommentLink(org.eclipse.jgit.lib.Config cfg, String name, boolean allowRaw)voidclearSubmitRequirements()voiderror(ValidationError error)AccessSectiongetAccessSection(String name)Returns an access section,nametypically is a ref pattern.Collection<AccessSection>getAccessSections()AccountsSectiongetAccountsSection()BranchOrderSectiongetBranchOrderSection()CachedProjectConfiggetCacheable()Returns an immutable, thread-safe representation of this object that can be cached.booleangetCheckReceivedObjects()Returns the checkReceivedObjects for this project, default is true.Collection<StoredCommentLinkInfo>getCommentLinkSections()ContributorAgreementgetContributorAgreement(String name)Collection<ContributorAgreement>getContributorAgreements()GroupReferencegetGroup(AccountGroup.UUID uuid)Returns the group reference, if the group is used by at least one rule.GroupReferencegetGroup(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()longgetMaxObjectSizeLimit()Returns the maxObjectSizeLimit configured on this project, or zero if not configured.ConfiguredMimeTypesgetMimeTypes()Project.NameKeygetName()Collection<NotifyConfig>getNotifyConfigs()PluginConfiggetPluginConfig(String pluginName)ProjectgetProject()protected StringgetRefName()Returns name of the reference storing this configuration.org.eclipse.jgit.lib.ObjectIdgetRulesId()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.booleanhasLegacyPermissions()voidload(org.eclipse.jgit.lib.Repository repo)voidload(org.eclipse.jgit.lib.Repository repo, org.eclipse.jgit.lib.ObjectId revision)voidload(org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.lib.ObjectId revision)protected voidonLoad()Set up the metadata, parsing any state from the loaded revision.protected booleanonSave(org.eclipse.jgit.lib.CommitBuilder commit)Save any changes to the metadata in a commit.voidputNotifyConfig(String name, NotifyConfig nc)voidremove(AccessSection section)voidremove(AccessSection section, Permission permission)voidremove(AccessSection section, Permission permission, PermissionRule rule)voidremoveCommentLinkSection(String name)voidrenameGroup(AccountGroup.UUID uuid, String newName)voidreplace(ContributorAgreement section)GroupReferenceresolve(GroupReference group)voidsetAccountsSection(AccountsSection accountsSection)voidsetBranchOrderSection(BranchOrderSection branchOrderSection)voidsetProject(Project.Builder project)booleanupdateGroupNames(GroupBackend groupBackend)Check all GroupReferences use current group name, repairing stale ones.voidupdateLabelType(String name, Consumer<LabelType.Builder> update)Allows a mutation of an existingLabelType.voidupdatePluginConfig(String pluginName, Consumer<PluginConfig.Update> pluginConfigUpdate)voidupdateProject(Consumer<Project.Builder> update)voidupsertAccessSection(String name, Consumer<AccessSection.Builder> update)voidupsertContributorAgreement(ContributorAgreement ca)Adds or replaces the givenContributorAgreementin this config.voidupsertLabelType(LabelType labelType)Adds or replaces the givenLabelTypein this config.voidupsertSubmitRequirement(SubmitRequirement requirement)Adds or replaces the givenSubmitRequirementin this config.static StringvalidMaxObjectSizeLimit(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:
IOExceptionorg.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:
IOExceptionorg.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:
IOExceptionorg.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,nametypically 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 givenSubmitRequirementin this config.
-
clearSubmitRequirements
public void clearSubmitRequirements()
-
upsertLabelType
public void upsertLabelType(LabelType labelType)
Adds or replaces the givenLabelTypein 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 givenContributorAgreementin 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:VersionedMetaDataReturns name of the reference storing this configuration.- Specified by:
getRefNamein classVersionedMetaData
-
onLoad
protected void onLoad() throws IOException, org.eclipse.jgit.errors.ConfigInvalidExceptionDescription copied from class:VersionedMetaDataSet up the metadata, parsing any state from the loaded revision.- Specified by:
onLoadin classVersionedMetaData- Throws:
IOExceptionorg.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.ConfigInvalidExceptionDescription copied from class:VersionedMetaDataSave any changes to the metadata in a commit.- Specified by:
onSavein classVersionedMetaData- Returns:
- true if the commit should proceed, false to abort.
- Throws:
IOExceptionorg.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:
errorin interfaceValidationError.Sink
-
hasLegacyPermissions
public boolean hasLegacyPermissions()
-
-