/plugin-module-codegen-engine/src/main/resources/templates/stash/idx/ChangesetIndexer.java.vtl
https://bitbucket.org/mmeinhold/amps · Unknown · 55 lines · 45 code · 10 blank · 0 comment · 0 complexity · b42f24a9f1290d746f260d912a0df9ab MD5 · raw file
- package ${PACKAGE};
- import com.atlassian.stash.content.Changeset;
- import com.atlassian.stash.idx.ChangesetIndexer;
- import com.atlassian.stash.idx.IndexingContext;
- import com.atlassian.stash.repository.Repository;
- import javax.annotation.Nonnull;
- public class ${CLASSNAME} implements ChangesetIndexer
- {
- @Nonnull
- @Override
- public String getId()
- {
- return "${MODULE_KEY}";
- }
- @Override
- public boolean isEnabledForRepository(@Nonnull Repository repository)
- {
- // enabled for all repositories
- return true;
- }
- @Override
- public void onBeforeIndexing(@Nonnull IndexingContext indexingContext)
- {
- // nothing to do before indexing run
- }
- @Override
- public void onAfterIndexing(@Nonnull IndexingContext indexingContext)
- {
- // nothing to do after indexing run
- }
- @Override
- public void onChangesetAdded(@Nonnull Changeset changeset, @Nonnull IndexingContext indexingContext)
- {
- // example code: add byAtlassian attribute to Atlassian authored changesets
- if (changeset.getAuthor().getEmailAddress().endsWith("@atlassian.com"))
- {
- indexingContext.put("byAtlassian", true);
- }
- }
- @Override
- public void onChangesetRemoved(@Nonnull Changeset changeset, @Nonnull IndexingContext indexingContext)
- {
- // nothing to do, changeset's attributes will be automatically cleaned up
- }
- }