jonahkh
2020-06-16 3cf2d17add33f2cb95cfa365860d84706aa110c2
adopt-a-pup/animal-service/src/main/java/com/redhat/do328/adoptApup/animalservice/service/AnimalService.java
@@ -18,7 +18,6 @@
import org.stringtemplate.v4.ST;
import org.stringtemplate.v4.STRawGroupDir;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -63,11 +62,9 @@
        if (!CollectionUtils.isEmpty(matchingNotificationCriteria)) {
            final Map<String, Email> templatesToEmail = matchingNotificationCriteria.stream()
                    .collect(Collectors.toMap(AnimalNotificationRequestCriteria::getEmail, criteria -> new Email(renderTemplate(criteria, animal), NOTIFICATION_REQUEST_SUBJECT)));
            final ResponseEntity<ResponseEntity> response = restTemplate.postForEntity(notificationServiceUrl + "/notifications/sendEmails", templatesToEmail, ResponseEntity.class);
            final ResponseEntity response = restTemplate.postForEntity(notificationServiceUrl + "/notifications/sendEmails", templatesToEmail, ResponseEntity.class);
            if (HttpStatus.OK.equals(response.getStatusCode())) {
                animalNotificationSubscriptionRepository.deleteAll(matchingNotificationCriteria);
            } else {
                // retry
            }
        }
@@ -81,15 +78,6 @@
            throw new ResponseStatusException(HttpStatus.NOT_FOUND, "animal not found for animal ID " + animalId);
        }
        return animal.get();
    }
    public List<String> createAnimalsBulk(List<Animal> animals, String shelterId) {
        final List<String> animalIds = new ArrayList<>();
        for (Animal animal : animals) {
            animal.setShelterId(shelterId);
            animalIds.add(createAnimal(animal));
        }
        return animalIds;
    }
    public void createNotificationSubscription(AnimalNotificationRequestCriteria criteria) {
@@ -106,8 +94,6 @@
        final ResponseEntity response = restTemplate.postForEntity(notificationServiceUrl + "/notifications/sendEmails", new EmailNotificationRequest(notificationRequest), ResponseEntity.class);
        if (HttpStatus.OK.equals(response.getStatusCode())) {
            animalNotificationSubscriptionRepository.delete(criteria);
        } else {
            // retry
        }
    }