/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

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