Acquire repository lock forcefully (fix #12359). (rebased onto dev_5_0)



This is the same as gh-2700 but rebased onto dev_5_0.

----

This PR aims to fix [ticket #12359](http://trac.openmicroscopy.org.uk/ome/ticket/12359). The situation described in the ticket was not possible to reproduce. Hence applying common sense here. The test class ``LegacyRepositoryUnitTest.java`` is now fixed.

To test:
- Verify that ``LegacyRepositoryUnitTest.java`` has no errors (``./build.py -f components/blitz/build.xml test -DTEST=ome/services/repo/test/LegacyRepositoryUnitTest`` - but only if your binary repo is ``/OMERO``),
- Verify that the server starts up,
- Verify that after server shutdown, the ``.lock`` file is deleted from ``/OMERO/ManagedRepository/.omero/repository/<uuid>/``

/cc @dpwrussell