Skip to content

Commit

Permalink
chore: extends logs in buildRecipientList job
Browse files Browse the repository at this point in the history
  • Loading branch information
jekutzsche committed Mar 25, 2022
1 parent 2cd3a4a commit 464f686
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import iris.client_bff.iris_messages.IrisMessageFolder.IrisMessageFolderIdentifier;
import iris.client_bff.iris_messages.eps.EPSIrisMessageClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

import java.util.List;
import java.util.Objects;
Expand All @@ -22,6 +23,7 @@

@Service
@RequiredArgsConstructor
@Slf4j
public class IrisMessageService {

private static final String[] SEARCH_FIELDS = { "subject_search", "hdAuthor.name_search", "hdRecipient.name_search" };
Expand All @@ -36,7 +38,16 @@ public class IrisMessageService {

@Scheduled(fixedDelayString = "${iris.client.message.build-recipient-list.delay:-}")
void buildRecipientList() {

log.info("Job 'buildRecipientList' was started.");

recipientListHolder = Try.of(irisMessageClient::getIrisMessageHdContacts);

if (recipientListHolder.isFailure()) {
log.info("Job 'buildRecipientList' has an exception.", recipientListHolder.getCause());
}

log.debug("Job 'buildRecipientList' is finished.");
}

public Optional<IrisMessage> findById(IrisMessageIdentifier messageId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public ResponseEntity<URI> createAndSendMessage(@Valid @RequestBody IrisMessageI
.buildAndExpand(sentMessage.getId())
.toUri();
return ResponseEntity.created(location).build();
} catch (Throwable e) {
} catch (Exception e) {
String errorMessage = e instanceof IrisMessageException ime
? ime.getErrorMessage()
: "iris_message.submission_error";
Expand Down Expand Up @@ -145,14 +145,19 @@ public ResponseEntity<List<IrisMessageHdContact>> getMessageHdContacts(
@RequestParam(defaultValue = "false") boolean includeOwn) {
validateField(search, FIELD_SEARCH);
try {
ArrayList<IrisMessageHdContact> irisMessageContacts = new ArrayList<>(irisMessageService.getHdContacts(search));
List<IrisMessageHdContact> irisMessageContacts = new ArrayList<>(irisMessageService.getHdContacts(search));
if (!includeOwn) {
IrisMessageHdContact ownContact = this.irisMessageService.getOwnHdContact();
irisMessageContacts.removeIf(c -> c.getId().equals(ownContact.getId()));
}
return ResponseEntity.ok(irisMessageContacts);
} catch (Throwable e) {
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "iris_message.missing_hd_contacts");
} catch (Exception e) {

String errorMessage = e instanceof IrisMessageException ime
? ime.getErrorMessage()
: "iris_message.missing_hd_contacts";

throw new ResponseStatusException(HttpStatus.BAD_REQUEST, errorMessage);
}
}

Expand Down

0 comments on commit 464f686

Please sign in to comment.