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

Commit

Permalink
refactor AddContentTable.java
Browse files Browse the repository at this point in the history
  • Loading branch information
ori0o0p committed Mar 16, 2024
1 parent fdf1970 commit 181b96d
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,27 @@ public AddContentTable(DocumentFacade documentFacade, RevisionComponent revision
public Mono<Void> execute(AddContentRequest request, String documentId) {
return userFacade.currentUser()
.zipWith(documentFacade.findDocumentById(documentId))
.flatMap(tuple -> checkUserPermissionAndVersion(tuple, request.version()))
.flatMap(tuple -> addDocumentContentTable(tuple, request))
.map(tuple -> checkUserPermissionAndVersion(tuple, request.version()))
.map(tuple -> addDocumentContentTable(tuple, request))
.flatMap(document -> documentFacade.saveDocument(document)
.then(createRevision(document)))
.onErrorMap(this::mapException);
}

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

updateDocumentEditorAndUpdatedDate.execute(document, user);
setDocumentContent(document, request.index(), request.title());
setDocument(document, user);

return Mono.just(document);
return document;
}

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

private void setDocumentContent(DefaultDocument document, String index, String title) {
Expand Down

0 comments on commit 181b96d

Please sign in to comment.