core: fix NPE for removing non existing template

The locking message assume the template being removed exist in the DB,
therefore NPE can be thrown there.
Added a null check and in case the template is null, we won't try to
lock the template (that is ok since the can-do-action phase is going to
fail anyway).

Change-Id: Id3eeb1d34d4e6320961ee8b360715b29003f1a68
Signed-off-by: Omer Frenkel <ofrenkel@redhat.com>
Signed-off-by: Arik Hadas <ahadas@redhat.com>