PageRenderTime 63ms CodeModel.GetById 47ms app.highlight 10ms RepoModel.GetById 2ms app.codeStats 0ms

/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
 1package ${PACKAGE};
 2
 3import com.atlassian.stash.content.Changeset;
 4import com.atlassian.stash.idx.ChangesetIndexer;
 5import com.atlassian.stash.idx.IndexingContext;
 6import com.atlassian.stash.repository.Repository;
 7
 8import javax.annotation.Nonnull;
 9
10public class ${CLASSNAME} implements ChangesetIndexer
11{
12
13    @Nonnull
14    @Override
15    public String getId()
16    {
17        return "${MODULE_KEY}";
18    }
19
20    @Override
21    public boolean isEnabledForRepository(@Nonnull Repository repository)
22    {
23        // enabled for all repositories
24        return true;
25    }
26
27    @Override
28    public void onBeforeIndexing(@Nonnull IndexingContext indexingContext)
29    {
30        // nothing to do before indexing run
31    }
32
33    @Override
34    public void onAfterIndexing(@Nonnull IndexingContext indexingContext)
35    {
36        // nothing to do after indexing run
37    }
38
39    @Override
40    public void onChangesetAdded(@Nonnull Changeset changeset, @Nonnull IndexingContext indexingContext)
41    {
42        // example code: add byAtlassian attribute to Atlassian authored changesets
43        if (changeset.getAuthor().getEmailAddress().endsWith("@atlassian.com"))
44        {
45            indexingContext.put("byAtlassian", true);
46        }
47    }
48
49    @Override
50    public void onChangesetRemoved(@Nonnull Changeset changeset, @Nonnull IndexingContext indexingContext)
51    {
52        // nothing to do, changeset's attributes will be automatically cleaned up
53    }
54
55}