refactored document REST api

Change-Id: If192ad3ca1580172d4cca4c7484d26e60c2f1263