Check that a value is present before calling Optional.get()

Fixes bug 1655

Change-Id: I6fdf8d5a0abab7af8bd95a2ebaaf68658c60d24e
Signed-off-by: Dave Tucker <djt@redhat.com>