summaryrefslogtreecommitdiffstats
path: root/openecomp-be
diff options
context:
space:
mode:
authorayalaben <Ayala.Benzvi@Amdocs.Com>2018-05-07 14:01:00 +0300
committerayalaben <ayala.benzvi@amdocs.com>2018-05-07 14:01:58 +0300
commit70a3309f5e3e531981691e08d74cf89fa832c2a4 (patch)
treeb42df01b4bab601909bc3396b8c3e5d971ffa577 /openecomp-be
parent310804a209a059c87cf50a08e7df9cc4a1121e3c (diff)
notify catalog on items action
Change-Id: I11aa241c0c74c1a426dc1eee30ec7adb09abdca4 Issue-ID: SDC-1257 Signed-off-by: ayalaben <ayala.benzvi@amdocs.com>
Diffstat (limited to 'openecomp-be')
-rw-r--r--openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/CatalogNotifier.java45
1 files changed, 25 insertions, 20 deletions
diff --git a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/CatalogNotifier.java b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/CatalogNotifier.java
index 48a4f9c3b6..f19de3d04a 100644
--- a/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/CatalogNotifier.java
+++ b/openecomp-be/api/openecomp-sdc-rest-webapp/item-rest/item-rest-services/src/main/java/org/openecomp/sdcrests/item/rest/services/CatalogNotifier.java
@@ -60,6 +60,7 @@ public class CatalogNotifier {
private static String notifyCatalogUrl;
private static ScheduledExecutorService executor = Executors.newScheduledThreadPool(1);
+ private static boolean executeNotificationFlag = true;
static {
@@ -72,38 +73,42 @@ public class CatalogNotifier {
try {
configurationMap = readFromFile(configurationYamlFile, reader);
+ Object protocol = configurationMap.get(PROTOCOL_KEY);
+ Object host = configurationMap.get(HOST_KEY);
+ Object port = configurationMap.get(PORT_KEY);
- } catch (IOException e) {
- throw new RuntimeException("Could not read configuration file configuration.yaml");
- }
-
- Object protocol = configurationMap.get(PROTOCOL_KEY);
- Object host = configurationMap.get(HOST_KEY);
- Object port = configurationMap.get(PORT_KEY);
+ if (protocol == null || host == null || port == null) {
+ LOGGER.error("Could not read configuration file configuration.yaml");
+ executeNotificationFlag = false;
+ }
- if (protocol == null || host == null || port == null) {
- throw new RuntimeException("Could not read configuration file configuration.yaml");
- }
+ if (configurationMap.get(URL_KEY) != null) {
+ String urlFormat = String.valueOf(configurationMap.get(URL_KEY));
+ notifyCatalogUrl =
+ String.format(urlFormat, String.valueOf(protocol), String.valueOf(host), String.valueOf(port));
- if (configurationMap.get(URL_KEY) != null) {
- String urlFormat = String.valueOf(configurationMap.get(URL_KEY));
- notifyCatalogUrl =
- String.format(urlFormat, String.valueOf(protocol), String.valueOf(host), String.valueOf(port));
+ } else {
+ notifyCatalogUrl = String.format(URL_DEFAULT_FORMAT, String.valueOf(protocol), String.valueOf(host),
+ String.valueOf(port));
+ }
- } else {
- notifyCatalogUrl = String.format(URL_DEFAULT_FORMAT, String.valueOf(protocol), String.valueOf(host),
- String.valueOf(port));
+ } catch (Exception e) {
+ LOGGER.error("Could not read configuration file configuration.yaml");
+ executeNotificationFlag = false;
}
}
public void execute(Collection<String> itemIds, ItemAction action, int numOfRetries) {
- String userId = SessionContextProviderFactory.getInstance().createInterface().get().getUser().getUserId();
+ if (executeNotificationFlag) {
- Callable callable = createCallable(JsonUtil.object2Json(itemIds), action, numOfRetries, userId);
+ String userId = SessionContextProviderFactory.getInstance().createInterface().get().getUser().getUserId();
- executor.submit(callable);
+ Callable callable = createCallable(JsonUtil.object2Json(itemIds), action, numOfRetries, userId);
+
+ executor.submit(callable);
+ }
}