aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/impl/NewNotificationsReaderRestImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/impl/NewNotificationsReaderRestImpl.java')
-rw-r--r--openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/impl/NewNotificationsReaderRestImpl.java19
1 files changed, 6 insertions, 13 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/impl/NewNotificationsReaderRestImpl.java b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/impl/NewNotificationsReaderRestImpl.java
index 86a3030bd3..7f2390b38a 100644
--- a/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/impl/NewNotificationsReaderRestImpl.java
+++ b/openecomp-be/lib/openecomp-sdc-notification-lib/openecomp-sdc-notification-worker/src/main/java/org/openecomp/sdc/notification/workers/impl/NewNotificationsReaderRestImpl.java
@@ -17,25 +17,23 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.sdc.notification.workers.impl;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.InputStreamReader;
+import java.util.UUID;
+import javax.ws.rs.core.HttpHeaders;
+import javax.ws.rs.core.MediaType;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.HttpClientBuilder;
-import com.fasterxml.jackson.databind.ObjectMapper;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdc.notification.config.ConfigurationManager;
import org.openecomp.sdc.notification.types.NotificationsStatusDto;
import org.openecomp.sdc.notification.workers.NewNotificationsReader;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import java.io.InputStreamReader;
-import java.util.UUID;
-
public class NewNotificationsReaderRestImpl implements NewNotificationsReader {
private static final String USER_ID_HEADER_PARAM = "USER_ID";
@@ -47,12 +45,10 @@ public class NewNotificationsReaderRestImpl implements NewNotificationsReader {
private static final int DEFAULT_BE_PORT = 8080;
private static final String URL = "http://%s:%d/onboarding-api/v1.0/notifications/worker?";
private static final ObjectMapper mapper = new ObjectMapper();
-
+ private static final Logger LOGGER = LoggerFactory.getLogger(NewNotificationsReaderRestImpl.class);
private static String beHost;
private static int bePort;
- private static final Logger LOGGER = LoggerFactory.getLogger(NewNotificationsReaderRestImpl.class);
-
public NewNotificationsReaderRestImpl() {
ConfigurationManager cm = ConfigurationManager.getInstance();
bePort = cm.getConfigValue(BE_PORT, DEFAULT_BE_PORT);
@@ -62,17 +58,14 @@ public class NewNotificationsReaderRestImpl implements NewNotificationsReader {
public NotificationsStatusDto getNewNotifications(String ownerId, UUID eventId, int limit) {
HttpClient client = HttpClientBuilder.create().build();
String url = String.format(URL, beHost, bePort);
-
url = url + LIMIT_QUERY_PARAM + "=" + limit;
if (eventId != null) {
url = url + "&" + LAST_DELIVERED_QUERY_PARAM + "=" + eventId;
}
-
HttpGet request = new HttpGet(url);
request.addHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
request.addHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
request.addHeader(USER_ID_HEADER_PARAM, ownerId);
-
try {
HttpResponse response = client.execute(request);
return mapper.readValue(new InputStreamReader(response.getEntity().getContent()), NotificationsStatusDto.class);