target.request().put( Entity.text( "\"" + serverAdminPassword + "\"" ) ).close();
}
private static void createDatabaseUser() throws Exception {
// 1.) create user
WebTarget target = client.target( serverUri + "/_users/org.couchdb.user:" + databaseUser );
Response response = target.request().put( Entity.text(
"{ " +
"\"_id\" : \"org.couchdb.user:" + databaseUser + "\", " +
"\"type\" : \"user\", " +
"\"name\" : \"" + databaseUser + "\", " +
"\"roles\" : [], " +
"\"password\" : \"" + databaseUserPassword + "\"" +
" }" )
);
String entity = response.readEntity( String.class );
databaseUserRevision = (String) new ObjectMapper().readValue( entity, Map.class ).get( "rev" );
response.close();
// 2.) make the user an admin of the database
target = client.target( serverUri + "/" + database + "/_security" );
response = target.request().put( Entity.text(
"{" +
"\"admins\": {" +
"\"names\":[\"" + databaseUser + "\"]," +
" \"roles\":[]" +
"}, " +