Package com.atlassian.bitbucket.idx
Interface CommitIndex
public interface CommitIndex
Index to store meta data against commits. This interface serves to decouple commit indexing from storing metadata in
an index.
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddCommit(Commit commit, Repository repository) Associates the providedCommitwith the specifiedRepository.booleanaddProperty(String commitId, String key, String value) Stores a string commit property.findByProperty(String propertyKey, String propertyValue, boolean caseSensitive, PageRequest pageRequest) Retrieves allindexed commitsthat have a given property with a specified value.Retrieves the specified commit if it's been indexed.getProperties(Iterable<String> commitIds, Iterable<String> propertyKeys) Retrieves a properties for each of the specified commits, matching the providedpropertyKeys.getProperties(String commitId, Iterable<String> propertyKeys) Retrieves a property map containing all properties stored against the given commit, matchingpropertyKeys.booleanisIndexed(String commitId, Repository repository) voidremoveCommit(String commitId, Repository repository) Removes the association between the specified commit and repository in the index.voidremoveProperty(String commitId, String key, String value) Removes a commit property.search(IndexSearchRequest searchRequest, PageRequest pageRequest) Searches the index for any matching commits.searchRepositoryCommits(IndexSearchRequest indexSearchRequest, PageRequest pageRequest) Search the index for anycommitsmatching the provided search request.
-
Method Details
-
addCommit
Associates the providedCommitwith the specifiedRepository.- Parameters:
commit- the commitrepository- the repository
-
addProperty
Stores a string commit property. If the property (name-value pair) already exists, calling this method will have no effect.- Parameters:
commitId- the commit IDkey- the property keyvalue- the property value- Returns:
trueif the property was created in the database,falseif it already existed.- Since:
- 8.13
-
findByProperty
@Nonnull Page<IndexedCommit> findByProperty(@Nonnull String propertyKey, @Nonnull String propertyValue, boolean caseSensitive, @Nonnull PageRequest pageRequest) Retrieves allindexed commitsthat have a given property with a specified value.- Parameters:
propertyKey- the property keypropertyValue- the property valuecaseSensitive- whether matches againstvalueshould be case-sensitivepageRequest- the page request- Returns:
- a page of
IndexedCommit commitsthat have the provided property. The results in the page are ordered byauthorTimestampdescending
-
getCommit
Retrieves the specified commit if it's been indexed.- Parameters:
commitId- thecommit ID- Returns:
- the
IndexedCommit, ornullif the specified commit has not been indexed
-
getProperties
@Nonnull PropertyMap getProperties(@Nonnull String commitId, @Nonnull Iterable<String> propertyKeys) Retrieves a property map containing all properties stored against the given commit, matchingpropertyKeys. The value of all the properties is of typeSet<String>.- Parameters:
commitId- the commit idpropertyKeys- the property keys to retrieve- Returns:
- properties for commit with
commitId, matchingpropertyKeys. Can be empty, but notnull.
-
getProperties
@Nonnull Map<String,PropertyMap> getProperties(@Nonnull Iterable<String> commitIds, @Nonnull Iterable<String> propertyKeys) Retrieves a properties for each of the specified commits, matching the providedpropertyKeys. The value of all the properties is of typeSet<String>.- Parameters:
commitIds- commit IDspropertyKeys- the property keys to retrieve for each commit- Returns:
- properties for each commit in
commitIds, matchingpropertyKeys, mapped by commit IDs. Can be empty, but notnull.
-
isIndexed
- Parameters:
commitId- thecommit IDrepository- the repository- Returns:
- true if the provided commit was indexed in the specified repository
-
removeCommit
Removes the association between the specified commit and repository in the index. If the specified repository was the only association for the commit, it will be fully removed from the index. Otherwise, the commit may still appear in the index if it is available in other repositories.- Parameters:
commitId- theIDof the commit to remove from the indexrepository- the repository to remove the commit's association for
-
removeProperty
Removes a commit property.- Parameters:
commitId- the commit IDkey- the property keyvalue- the property value
-
search
@Nonnull Page<IndexedCommit> search(@Nonnull IndexSearchRequest searchRequest, @Nonnull PageRequest pageRequest) Searches the index for any matching commits.- Parameters:
searchRequest- the criteria to matchpageRequest- a pageRequest to delimit the search- Returns:
- a page of
IndexedCommits, possibly empty if no indexed commits match
-
searchRepositoryCommits
@Nonnull Page<MinimalRepositoryCommit> searchRepositoryCommits(@Nonnull IndexSearchRequest indexSearchRequest, @Nonnull PageRequest pageRequest) throws IllegalArgumentException Search the index for anycommitsmatching the provided search request. Only commits in repositories that the current user has access to will be returned. The providedfiltershould be at least 7 characters long.- Parameters:
indexSearchRequest- the search requestpageRequest- the page request- Returns:
- a page of
commitsthat match the criteria and that are in repositories the current user has access to - Throws:
IllegalArgumentException- ifcriteria.getFilter()is less than 7 characters- Since:
- 5.8
-