Reordered: save object first, then update latestHead flag.

(fixLatestHeadAndBranch requires a db-lookup, which would fail on unsaved instances)
Cinnamon 2.5.0: refactored IndexServer, added IndexJob

The new IndexServer will index a class based on index job objects and no longer changes the indexed objects. The advantage is two-fold:
1. Eliminate race-condition between IndexServer and other processes trying to update an object.
2. In case of a server crash (or database rollback), the Lucene index will not contain objects that do not exist in the database.