Put draft endpoint: Use delete draft endpoint directly

Put draft and delete draft endpoint are both now in singleton scope.
In this case usage of Provider doesn't make any sense.

Change-Id: I3610ec65b3bcb3b33c69f75520a3686d6152519d
This commit is contained in:
David Ostrovsky 2014-06-20 10:39:37 +02:00 committed by David Pursehouse
parent 41df0f56e6
commit 3080b6fc0d

View File

@ -50,10 +50,10 @@ class PutDraft implements RestModifyView<DraftResource, Input> {
} }
private final Provider<ReviewDb> db; private final Provider<ReviewDb> db;
private final Provider<DeleteDraft> delete; private final DeleteDraft delete;
@Inject @Inject
PutDraft(Provider<ReviewDb> db, Provider<DeleteDraft> delete) { PutDraft(Provider<ReviewDb> db, DeleteDraft delete) {
this.db = db; this.db = db;
this.delete = delete; this.delete = delete;
} }
@ -63,7 +63,7 @@ class PutDraft implements RestModifyView<DraftResource, Input> {
BadRequestException, OrmException { BadRequestException, OrmException {
PatchLineComment c = rsrc.getComment(); PatchLineComment c = rsrc.getComment();
if (in == null || in.message == null || in.message.trim().isEmpty()) { if (in == null || in.message == null || in.message.trim().isEmpty()) {
return delete.get().apply(rsrc, null); return delete.apply(rsrc, null);
} else if (in.id != null && !rsrc.getId().equals(in.id)) { } else if (in.id != null && !rsrc.getId().equals(in.id)) {
throw new BadRequestException("id must match URL"); throw new BadRequestException("id must match URL");
} else if (in.line != null && in.line < 0) { } else if (in.line != null && in.line < 0) {