Refactoring of lock mechanism.

Refactoring:
- move Base.edit, Base.post_graph, KtbsRoot.edit, KtbsRoot.post_graph to WithLock.edit and WithLock.post_graph respectively.
- move Base.delete to WithLock.delete, KtbsRoot.delete is kept as it needs to return a MethodNotAllowed exception.
- move Base.lock enhancements to WithLock.lock as other derived class of WithLock could use it.

Fix:
- the checking of the existence of a resource prior to its deletion is now done after getting a lock, this prevents the case were we would assert that the resource exists, then another process delete the resource, then we would try to get the lock for this non-existing resource.