Refactor selection of repository/observer based on argument

Move the complex logic used to choose the document type to be
republished, and obtain its observers and registries down into a
testable class and away from the (untested) republish_documents script.
Given that this change further removes these values from the place that uses them, it would be nice to start using structs instead of arrays.