}
else {
response = databaseClient.saveDocument( document, document.getId() );
}
if ( response.getStatus() == Response.Status.CREATED.getStatusCode() ) {
GenericResponse entity = response.readEntity( GenericResponse.class );
updateDocumentRevision( document, entity.getRev() );
}
else if ( response.getStatus() == Response.Status.CONFLICT.getStatusCode() ) {
throw logger.getDocumentHasBeenConcurrentlyModifiedException( document.getId() );
}
else {
GenericResponse entity = response.readEntity( GenericResponse.class );
throw logger.errorCreatingDocument( response.getStatus(), entity.getError(), entity.getReason() );
}
return document;
}
catch (ResteasyClientException e) {
throw logger.couchDBConnectionProblem( e );