Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
refactor EditContentTableTitle.java
Browse files Browse the repository at this point in the history
  • Loading branch information
ori0o0p committed Mar 16, 2024
1 parent 9ca353d commit e89759f
Showing 1 changed file with 3 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,15 @@ public EditContentTableTitle(DocumentFacade documentFacade, RevisionComponent re
public Mono<Void> execute(EditContentTableTitleRequest request, String documentId) {
return userFacade.currentUser()
.zipWith(documentFacade.findDocumentById(documentId))
.map(tuple -> checkUserPermissionAndVersion(tuple, request.version()))
.flatMap(tuple -> updateDocument(tuple, request))
.flatMap(tuple -> checkPermissionAndUpdateDocument(tuple, request))
.subscribeOn(scheduler)
.flatMap(document -> documentFacade.saveDocument(document)
.then(createRevision(document)));
}

private Tuple2<User, DefaultDocument> checkUserPermissionAndVersion(Tuple2<User, DefaultDocument> tuple, int version) {
userFilter.userPermissionAndDocumentVersionCheck(tuple.getT2(), tuple.getT1().getEmail(), version);
return tuple;
}
private Mono<DefaultDocument> checkPermissionAndUpdateDocument(Tuple2<User, DefaultDocument> tuple, EditContentTableTitleRequest request) {
userFilter.userPermissionAndDocumentVersionCheck(tuple.getT2(), tuple.getT1().getEmail(), request.version());

private Mono<DefaultDocument> updateDocument(Tuple2<User, DefaultDocument> tuple, EditContentTableTitleRequest request) {
DefaultDocument document = tuple.getT2();
User user = tuple.getT1();

Expand Down

0 comments on commit e89759f

Please sign in to comment.