I call another microservice to check whether there is any holiday on any particular day. This will then add a comment in the db if the rest call doesn't fetch an empty list(a list of size 1).

Here is the code in service:

    public void updateMeetingStatus() {
        List<DialogueEntity> dialogueEntities = dialogueDBRepo.getChildDialogueToUpdate();
        dialogueEntities.forEach(dialogueEntity -> {
            if (Boolean.TRUE.equals(checkAndMarkSkipped(dialogueEntity))) {
                logger.info("Holiday detected for updateMeetingStatus");
                        "Dialogue Skipped because originator/participant location has holiday on this particular date!");
            updateDialogueStatus(dialogueEntity, DialogueStatus.SKIPPED.getStatus());

        List<DialogueEntity> parentDialogues = dialogueDBRepo.getParentDialoguesToUpdate();
        if (!CollectionUtils.isEmpty(parentDialogues)) {
            parentDialogues = parentDialogues.stream()
                    .map(dialogueEntity -> updateDialogueStatus(dialogueEntity, DialogueStatus.CLOSED.getStatus()))
private Boolean checkAndMarkSkipped(DialogueEntity entity) {
        String originator = entity.getOriginatorNtnet();
        EmployeeHierarchyEntity originatorLoc = hierarchyDBRepo.findByNtNetId(originator);
        String originatorLocation = originatorLoc.getLocation();
        String participant = entity.getParticipantNtnet();
        EmployeeHierarchyEntity participantLoc = hierarchyDBRepo.findByNtNetId(participant);
        String participantLocation = participantLoc.getLocation();
        if (Boolean.TRUE.equals(!checkIfHolidayExists(entity.getDateOfDialogue(), originatorLocation))
                || Boolean.TRUE.equals(!checkIfHolidayExists(entity.getDateOfDialogue(), participantLocation))) {
            return true;
        return false;
private Boolean checkIfHolidayExists(LocalDate dateOfDialogue, String originatorLoc) {
        List<Date> date = restClientService.getHolidaysBetweenDates(
                Date.from(dateOfDialogue.atStartOfDay(ZoneId.systemDefault()).toInstant()), originatorLoc,
        return date.isEmpty();
    public List<Date> getHolidaysBetweenDates(Date fromDate, Date toDate, String holidayLocation, String token) {
        ResponseEntity<List<Date>> response = holidayServiceRestClient.getHolidaysBetweenDates(holidayLocation, fromDate, toDate, token);
        if (response.getStatusCode() == HttpStatus.OK) {
            return response.getBody();
        } else if (response.getStatusCode() == HttpStatus.NO_CONTENT) {
            logger.error("Holidays not found!");
        return new ArrayList<>();


public class JwtGenerator {

    private JwtGenerator(){

    private static final String SECRET_KEY = "${jwt.config.secrate_key}";

    public static String generateJwt(String subject) {
        long nowMillis = System.currentTimeMillis();
        Date now = new Date(nowMillis);

        long expirationMillis = nowMillis + 3600000; // Set expiration time to 1 hour from now
        Date expiration = new Date(expirationMillis);

        return Jwts.builder()
                    .signWith(SignatureAlgorithm.HS256, SECRET_KEY)

  • 4
    \$\begingroup\$ Please do not post fragments of your code. Post it in its entirety. \$\endgroup\$
    – slepic
    Apr 11, 2023 at 16:54

1 Answer 1


Well... from what I've managed to understand, your code is designed to update the meeting status based on whether there is a holiday on the meeting date for either the originator or the participant. The code makes use of a separate microservice to fetch holidays and check if the meeting date is a holiday or not. If a holiday is detected, the meeting status is updated with a comment stating that it was skipped due to a holiday at the location.


The logic seems to be clear and functional, but there are a few suggestions to improve the code:

  • Use Java 8 features - prefer Optional and functional programming constructs for better readability and conciseness.
  • Simplify some of the conditions in the checkAndMarkSkipped method.
  • Consider using LocalDate instead of Date for more modern date handling in the getHolidaysBetweenDates method
  • Replace Boolean with the primitive boolean in checkAndMarkSkipped method, and simplified the conditionals
  • Replace Date with LocalDate in getHolidaysBetweenDates method

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.