refactored document REST api

Change-Id: I04584b5a760b176bc3cb069fbd53ef6e7d7b3261