refactored document REST api

Change-Id: I35629a418bd4f4494b98c1485f9470cb5814063a