/*
 * This program is part of the OpenLMIS logistics management information system platform software.
 * Copyright © 2017 VillageReach
 *
 * This program is free software: you can redistribute it and/or modify it under the terms
 * of the GNU Affero General Public License as published by the Free Software Foundation, either
 * version 3 of the License, or (at your option) any later version.
 *  
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 * See the GNU Affero General Public License for more details. You should have received a copy of
 * the GNU Affero General Public License along with this program. If not, see
 * http://www.gnu.org/licenses.  For additional information contact info@OpenLMIS.org. 
 */

package org.openlmis.stockmanagement.service;

import org.openlmis.stockmanagement.dto.referencedata.UserDto;
import org.openlmis.stockmanagement.util.RequestHelper;
import org.openlmis.util.NotificationRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestOperations;
import org.springframework.web.client.RestTemplate;

@Service
public class NotificationService {
  private final Logger logger = LoggerFactory.getLogger(getClass());

  @Autowired
  private AuthService authService;

  @Value("${notification.url}")
  private String notificationUrl;

  @Value("${email.noreply}")
  private String from;

  private RestOperations restTemplate = new RestTemplate();

  /**
   * Send an email notification.
   *
   * @param user    receiver of the notification
   * @param subject subject of the email
   * @param content content of the email
   * @return true if success, false if failed.
   */
  public boolean notify(UserDto user, String subject, String content) {
    NotificationRequest request = new NotificationRequest(
        from, user.getEmail(), subject, content
    );
    
    try {
      restTemplate.postForObject(
          RequestHelper.createUri(notificationUrl),
          RequestHelper.createEntity(authService.obtainAccessToken(),
              request),
          Object.class);
    } catch (RestClientException ex) {
      logger.error("Can not send notification ", ex);
      return false;
    }
    return true;
  }
}

@@ -1324,26 +1324,30 @@
 .client.
-RestClient
+HttpStatusCode
 Exceptio
@@ -2451,18 +2451,22 @@
 ch (
-RestClient
+HttpStatusCode
 Exce
@@ -2500,40 +2500,153 @@
 ror(
-%22Can not send notification %22, ex
+%0A          %22Unable to send notification. Error code: %7B%7D, response message: %7B%7D%22,%0A          ex.getStatusCode(), ex.getResponseBodyAsString()%0A      
 );%0A 

Modify logger message