Package com.google.gerrit.server.project
Class ProjectState
- java.lang.Object
-
- com.google.gerrit.server.project.ProjectState
-
public class ProjectState extends Object
State of a project, aggregated from the project and its parents. This is obtained from theProjectCache. It should not be persisted across requests
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classProjectState.EffectiveMaxObjectSizeLimitstatic interfaceProjectState.Factory
-
Field Summary
Fields Modifier and Type Field Description static StringINHERITED_FROM_GLOBALstatic StringINHERITED_FROM_PARENTstatic StringOVERRIDDEN_BY_GLOBALstatic StringOVERRIDDEN_BY_PARENT
-
Constructor Summary
Constructors Constructor Description ProjectState(ProjectCache projectCache, AllProjectsName allProjectsName, AllUsersName allUsersName, List<CommentLinkInfo> commentLinks, CapabilityCollection.Factory limitsFactory, TransferConfig transferConfig, CachedProjectConfig cachedProjectConfig)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckStatePermitsRead()voidcheckStatePermitsWrite()Set<GroupReference>getAllGroups()Set<AccountGroup.UUID>getAllOwners()Returns allAccountGroup's that are allowed to administrate the complete project.List<SectionMatcher>getAllSections()Obtain all local and inherited sections.Optional<BranchOrderSection>getBranchOrderSection()CapabilityCollectiongetCapabilityCollection()Returns cached computation of all global capabilities.List<CommentLinkInfo>getCommentLinks()CachedProjectConfiggetConfig()ProjectLevelConfiggetConfig(String fileName)ProjectState.EffectiveMaxObjectSizeLimitgetEffectiveMaxObjectSizeLimit()LabelTypesgetLabelTypes()All available label types.LabelTypesgetLabelTypes(BranchNameKey destination)All available label types for this branch.LabelTypesgetLabelTypes(ChangeNotes notes)All available label types for this change.Set<GroupReference>getLocalGroups()longgetMaxObjectSizeLimit()StringgetName()Project.NameKeygetNameKey()Set<AccountGroup.UUID>getOwners()Returns allAccountGroup's to which the owner privilege for 'refs/*' is assigned for this project (the local owners), if there are no local owners the local owners of the nearest parent project that has local owners are returnedPluginConfiggetPluginConfig(String pluginName)ProjectgetProject()Map<String,SubmitRequirement>getSubmitRequirements()Get all submit requirements for a project, including those from parent projects.SubmitTypegetSubmitType()Collection<SubscribeSection>getSubscribeSections(BranchNameKey branch)booleanhasPrologRules()Returns true if the Prolog engine is expected to run for this project, that is if this project or a parent possesses a rules.pl file.booleanis(BooleanProjectConfig config)booleanisAllProjects()booleanisAllUsers()com.google.common.collect.FluentIterable<ProjectState>parents()Returns an iterable that walks through the parents of this project.booleanstatePermitsRead()booleanstatePermitsWrite()com.google.gerrit.index.project.ProjectDatatoProjectData()Iterable<ProjectState>tree()Returns an iterable that walks through this project and then the parents of this project.Iterable<ProjectState>treeInOrder()Returns an iterable that walks in-order from All-Projects through the project hierarchy to this project.
-
-
-
Field Detail
-
INHERITED_FROM_PARENT
public static final String INHERITED_FROM_PARENT
- See Also:
- Constant Field Values
-
OVERRIDDEN_BY_PARENT
public static final String OVERRIDDEN_BY_PARENT
- See Also:
- Constant Field Values
-
INHERITED_FROM_GLOBAL
public static final String INHERITED_FROM_GLOBAL
- See Also:
- Constant Field Values
-
OVERRIDDEN_BY_GLOBAL
public static final String OVERRIDDEN_BY_GLOBAL
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
ProjectState
@Inject public ProjectState(ProjectCache projectCache, AllProjectsName allProjectsName, AllUsersName allUsersName, List<CommentLinkInfo> commentLinks, CapabilityCollection.Factory limitsFactory, TransferConfig transferConfig, CachedProjectConfig cachedProjectConfig)
-
-
Method Detail
-
getCapabilityCollection
public CapabilityCollection getCapabilityCollection()
Returns cached computation of all global capabilities. This should only be invoked on the state fromProjectCache.getAllProjects(). Null on any other project.
-
hasPrologRules
public boolean hasPrologRules()
Returns true if the Prolog engine is expected to run for this project, that is if this project or a parent possesses a rules.pl file.
-
getProject
public Project getProject()
-
getNameKey
public Project.NameKey getNameKey()
-
getName
public String getName()
-
getConfig
public CachedProjectConfig getConfig()
-
getConfig
public ProjectLevelConfig getConfig(String fileName)
-
getMaxObjectSizeLimit
public long getMaxObjectSizeLimit()
-
statePermitsRead
public boolean statePermitsRead()
-
checkStatePermitsRead
public void checkStatePermitsRead() throws ResourceConflictException- Throws:
ResourceConflictException
-
statePermitsWrite
public boolean statePermitsWrite()
-
checkStatePermitsWrite
public void checkStatePermitsWrite() throws ResourceConflictException- Throws:
ResourceConflictException
-
getEffectiveMaxObjectSizeLimit
public ProjectState.EffectiveMaxObjectSizeLimit getEffectiveMaxObjectSizeLimit()
-
getAllSections
public List<SectionMatcher> getAllSections()
Obtain all local and inherited sections. This collection is looked up dynamically and is not cached. Callers should try to cache this result per-request as much as possible.
-
getOwners
public Set<AccountGroup.UUID> getOwners()
Returns allAccountGroup's to which the owner privilege for 'refs/*' is assigned for this project (the local owners), if there are no local owners the local owners of the nearest parent project that has local owners are returned
-
getAllOwners
public Set<AccountGroup.UUID> getAllOwners()
Returns allAccountGroup's that are allowed to administrate the complete project. This includes all groups to which the owner privilege for 'refs/*' is assigned for this project (the local owners) and all groups to which the owner privilege for 'refs/*' is assigned for one of the parent projects (the inherited owners).
-
tree
public Iterable<ProjectState> tree()
Returns an iterable that walks through this project and then the parents of this project. Starts from this project and progresses up the hierarchy to All-Projects.
-
treeInOrder
public Iterable<ProjectState> treeInOrder()
Returns an iterable that walks in-order from All-Projects through the project hierarchy to this project.
-
parents
public com.google.common.collect.FluentIterable<ProjectState> parents()
Returns an iterable that walks through the parents of this project. Starts from the immediate parent of this project and progresses up the hierarchy to All-Projects.
-
isAllProjects
public boolean isAllProjects()
-
isAllUsers
public boolean isAllUsers()
-
is
public boolean is(BooleanProjectConfig config)
-
getSubmitRequirements
public Map<String,SubmitRequirement> getSubmitRequirements()
Get all submit requirements for a project, including those from parent projects.
-
getLabelTypes
public LabelTypes getLabelTypes()
All available label types.
-
getLabelTypes
public LabelTypes getLabelTypes(ChangeNotes notes)
All available label types for this change.
-
getLabelTypes
public LabelTypes getLabelTypes(BranchNameKey destination)
All available label types for this branch.
-
getCommentLinks
public List<CommentLinkInfo> getCommentLinks()
-
getPluginConfig
public PluginConfig getPluginConfig(String pluginName)
Returns thePluginConfigthat got parsed from thepluginssection ofproject.config. The returned instance is a defensive copy of the cached value. Returns an empty config in case we find no config for the given plugin name. This is useful when callingPluginConfig#withInheritance(ProjectState.Factory)
-
getBranchOrderSection
public Optional<BranchOrderSection> getBranchOrderSection()
-
getSubscribeSections
public Collection<SubscribeSection> getSubscribeSections(BranchNameKey branch)
-
getAllGroups
public Set<GroupReference> getAllGroups()
-
getLocalGroups
public Set<GroupReference> getLocalGroups()
-
getSubmitType
public SubmitType getSubmitType()
-
toProjectData
public com.google.gerrit.index.project.ProjectData toProjectData()
-
-