diff --git a/platform-jobs/samza/auto-creator/pom.xml b/platform-jobs/samza/auto-creator/pom.xml
index 1b9877748c..b192376024 100644
--- a/platform-jobs/samza/auto-creator/pom.xml
+++ b/platform-jobs/samza/auto-creator/pom.xml
@@ -9,7 +9,7 @@
4.0.0
auto-creator
- 0.0.23
+ 0.0.25
diff --git a/platform-jobs/samza/auto-creator/src/main/java/org/ekstep/jobs/samza/util/ContentUtil.java b/platform-jobs/samza/auto-creator/src/main/java/org/ekstep/jobs/samza/util/ContentUtil.java
index 2a49a6e7be..cb7371cea5 100644
--- a/platform-jobs/samza/auto-creator/src/main/java/org/ekstep/jobs/samza/util/ContentUtil.java
+++ b/platform-jobs/samza/auto-creator/src/main/java/org/ekstep/jobs/samza/util/ContentUtil.java
@@ -174,8 +174,8 @@ private void updateStatus(String channelId, String identifier, String message) t
else
throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Content update status Call Failed For : " + identifier);
} else {
- LOGGER.info("ContentUtil :: updateStatus :: Invalid Response received while updating failed status for : " + identifier + " | Response Code : " + resp.getResponseCode().toString() + " | Result : " + resp.getResult() + " | Error Message : " + resp.getParams().getErrmsg());
- throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Invalid Response received while updating content status for : " + identifier + " | Response Code : " + resp.getResponseCode().toString() + " | Result : " + resp.getResult() + " | Error Message : " + resp.getParams().getErrmsg());
+ LOGGER.info("ContentUtil :: updateStatus :: Invalid Response received while updating failed status for : " + identifier + getErrorDetails(resp));
+ throw new ServerException("ERR_API_CALL", "Invalid Response received while updating content status for : " + identifier + getErrorDetails(resp));
}
}
@@ -225,8 +225,8 @@ private Map searchContent(String identifier) throws Exception {
LOGGER.info("ContentUtil :: searchContent :: Received 0 count while searching content for : " + identifier);
} else {
- LOGGER.info("ContentUtil :: searchContent :: Invalid Response received while searching content for : " + identifier + " | Response Code : " + resp.getResponseCode().toString());
- throw new ServerException("ERR_API_CALL", "Invalid Response received while searching content for : " + identifier + " | Response Code : " + resp.getResponseCode().toString() + " | Result : " + resp.getResult() + " | Error Message : " + resp.getParams().getErrmsg());
+ LOGGER.info("ContentUtil :: searchContent :: Invalid Response received while searching content for : " + identifier + getErrorDetails(resp));
+ throw new ServerException("ERR_API_CALL", "Invalid Response received while searching content for : " + identifier + getErrorDetails(resp));
}
return result;
}
@@ -275,8 +275,8 @@ private Map create(String channelId, String identifier, String n
contentId = (String) resp.getResult().get("identifier");
LOGGER.info("ContentUtil :: create :: Content Created Successfully with identifier : " + contentId);
} else {
- LOGGER.info("ContentUtil :: create :: Invalid Response received while creating content for : " + identifier + " | Response Code : " + resp.getResponseCode().toString() + " | Result : " + resp.getResult() + " | Error Message : " + resp.getParams().getErrmsg());
- throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Invalid Response received while creating content for : " + identifier+ " | Response Code : " + resp.getResponseCode().toString() + " | Result : " + resp.getResult() + " | Error Message : " + resp.getParams().getErrmsg());
+ LOGGER.info("ContentUtil :: create :: Invalid Response received while creating content for : " + identifier + getErrorDetails(resp));
+ throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Invalid Response received while creating content for : " + identifier+ getErrorDetails(resp));
}
return resp.getResult();
}
@@ -296,8 +296,8 @@ private Map read(String channelId, String identifier) throws Exc
LOGGER.info("ContentUtil :: read :: Content Fetched Successfully with identifier : " + contentId);
else throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Invalid Response received while reading content for : " + identifier);
} else {
- LOGGER.info("ContentUtil :: read :: Invalid Response received while reading content for : " + identifier + " | Response Code : " + resp.getResponseCode().toString() + " | Result : " + resp.getResult() + " | Error Message : " + resp.getParams().getErrmsg());
- throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Invalid Response received while reading content for : " + identifier + " | Response Code : " + resp.getResponseCode().toString() + " | Result : " + resp.getResult() + " | Error Message : " + resp.getParams().getErrmsg());
+ LOGGER.info("ContentUtil :: read :: Invalid Response received while reading content for : " + identifier + getErrorDetails(resp));
+ throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Invalid Response received while reading content for : " + identifier + getErrorDetails(resp));
}
return ((Map) resp.getResult().getOrDefault("content", new HashMap()));
}
@@ -319,8 +319,8 @@ private void update(String channelId, String internalId, Map upd
String contentId = (String) resp.getResult().get("identifier");
LOGGER.info("ContentUtil :: update :: Content Update Successfully having identifier : " + contentId);
} else {
- LOGGER.info("ContentUtil :: update :: Invalid Response received while updating content for : " + internalId + " | Response Code : " + resp.getResponseCode().toString() + " | Result : " + resp.getResult() + " | Error Message : " + resp.getParams().getErrmsg());
- throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Invalid Response received while updating content for : " + internalId + "| Response Code : " + resp.getResponseCode().toString() + " | Result : " + resp.getResult() + " | Error Message : " + resp.getParams().getErrmsg());
+ LOGGER.info("ContentUtil :: update :: Invalid Response received while updating content for : " + internalId + getErrorDetails(resp));
+ throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Invalid Response received while updating content for : " + internalId + getErrorDetails(resp));
}
}
@@ -341,7 +341,7 @@ private void update(String channelId, String internalId, Map upd
if (StringUtils.isNotBlank(artifactUrl) && StringUtils.equalsIgnoreCase(fileUrl, artifactUrl))
LOGGER.info("ContentUtil :: upload :: Content Uploaded Successfully for : " + identifier + " | artifactUrl : " + artifactUrl);
} else {
- LOGGER.info("ContentUtil :: upload :: Invalid Response received while uploading for: " + identifier + " | Response Code : " + resp.getResponseCode().toString() + " | Result : " + resp.getResult() + " | Error Message : " + resp.getParams().getErrmsg());
+ LOGGER.info("ContentUtil :: upload :: Invalid Response received while uploading for: " + identifier + getErrorDetails(resp));
throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Invalid Response received while uploading : " + identifier);
}
} else {
@@ -400,8 +400,8 @@ private Boolean upload(String channelId, String identifier, Map
return true;
}
} else {
- LOGGER.info("ContentUtil :: upload :: Invalid Response received while uploading for: " + identifier + " | Response Code : " + resp.getResponseCode().toString() + " | Result : " + resp.getResult() + " | Error Message : " + resp.getParams().getErrmsg());
- throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Invalid Response received while uploading : " + identifier + " | Response Code : " + resp.getResponseCode().toString() + " | Result : " + resp.getResult() + " | Error Message : " + resp.getParams().getErrmsg());
+ LOGGER.info("ContentUtil :: upload :: Invalid Response received while uploading for: " + identifier + getErrorDetails(resp));
+ throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Invalid Response received while uploading : " + identifier + getErrorDetails(resp));
}
return false;
}
@@ -426,8 +426,8 @@ private Boolean review(String channelId, String identifier) throws Exception {
return true;
}
} else {
- LOGGER.info("ContentUtil :: review :: Invalid Response received while sending content to review for : " + identifier + " | Response Code : " + resp.getResponseCode().toString() + " | Result : " + resp.getResult() + " | Error Message : " + resp.getParams().getErrmsg());
- throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Invalid Response received while sending content to review for : " + identifier + "| Response Code : " + resp.getResponseCode().toString() + " | Result : " + resp.getResult() + " | Error Message : " + resp.getParams().getErrmsg());
+ LOGGER.info("ContentUtil :: review :: Invalid Response received while sending content to review for : " + identifier + getErrorDetails(resp));
+ throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Invalid Response received while sending content to review for : " + identifier + getErrorDetails(resp));
}
return false;
}
@@ -455,8 +455,8 @@ private Boolean publish(String channelId, String identifier, String lastPublishe
else
throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Content Publish Call Failed For : " + identifier);
} else {
- LOGGER.info("ContentUtil :: publish :: Invalid Response received while publishing content for : " + identifier + " | Response Code : " + resp.getResponseCode().toString() + " | Result : " + resp.getResult() + " | Error Message : " + resp.getParams().getErrmsg());
- throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Invalid Response received while publishing content for : " + identifier + " | Response Code : " + resp.getResponseCode().toString() + " | Result : " + resp.getResult() + " | Error Message : " + resp.getParams().getErrmsg());
+ LOGGER.info("ContentUtil :: publish :: Invalid Response received while publishing content for : " + identifier + getErrorDetails(resp));
+ throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Invalid Response received while publishing content for : " + identifier + getErrorDetails(resp));
}
}
@@ -479,8 +479,8 @@ private String getPreSignedUrl(String identifier, String fileName) throws Except
preSignedUrl = (String) resp.getResult().get("pre_signed_url");
return preSignedUrl;
} else {
- LOGGER.info("ContentUtil :: getPreSignedUrl :: Invalid Response received while generating pre-signed url for : " + identifier + " | Response Code : " + resp.getResponseCode().toString());
- throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Invalid Response received while generating pre-signed url for : " + identifier);
+ LOGGER.info("ContentUtil :: getPreSignedUrl :: Invalid Response received while generating pre-signed url for : " + identifier + getErrorDetails(resp));
+ throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Invalid Response received while generating pre-signed url for : " + identifier + getErrorDetails(resp));
}
}
@@ -576,8 +576,8 @@ private Boolean addToHierarchy(String channel, String textbookId, Map getHierarchy(String identifier) throws Exception {
result = (Map) resp.getResult().getOrDefault("content", new HashMap());
return result;
} else {
- LOGGER.info("ContentUtil :: getHierarchy :: Invalid Response received while fetching hierarchy for : " + identifier + " | Response Code : " + resp.getResponseCode().toString());
- throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Invalid Response received while fetching hierarchy for : " + identifier + " | Response Code : " + resp.getResponseCode().toString() + " | Result : " + resp.getResult() + " | Error Message : " + resp.getParams().getErrmsg());
+ LOGGER.info("ContentUtil :: getHierarchy :: Invalid Response received while fetching hierarchy for : " + identifier + getErrorDetails(resp));
+ throw new ServerException(TaxonomyErrorCodes.SYSTEM_ERROR.name(), "Invalid Response received while fetching hierarchy for : " + identifier + getErrorDetails(resp));
}
}
@@ -656,4 +656,8 @@ private void delay(long time) {
}
}
+ private static String getErrorDetails(Response resp) {
+ return (null != resp) ? (" | Response Code :" + resp.getResponseCode().toString() + " | Result : " + resp.getResult() + " | Error Message : " + resp.getParams().getErrmsg()) : " | Null Response Received.";
+ }
+
}
diff --git a/platform-jobs/samza/auto-creator/src/main/java/org/ekstep/jobs/samza/util/UnirestUtil.java b/platform-jobs/samza/auto-creator/src/main/java/org/ekstep/jobs/samza/util/UnirestUtil.java
index 628bdbcb2b..97cf322dbb 100644
--- a/platform-jobs/samza/auto-creator/src/main/java/org/ekstep/jobs/samza/util/UnirestUtil.java
+++ b/platform-jobs/samza/auto-creator/src/main/java/org/ekstep/jobs/samza/util/UnirestUtil.java
@@ -29,9 +29,9 @@ public static Response post(String url, Map requestMap, Map response = Unirest.post(url).headers(headerParam).body(mapper.writeValueAsString(requestMap)).asString();
- resp = getResponse(response);
+ resp = getResponse(url, response);
}
return resp;
} catch (Exception e) {
@@ -46,9 +46,9 @@ public static Response patch(String url, Map requestMap, Map response = Unirest.patch(url).headers(headerParam).body(mapper.writeValueAsString(requestMap)).asString();
- resp = getResponse(response);
+ resp = getResponse(url, response);
}
return resp;
} catch (Exception e) {
@@ -63,9 +63,9 @@ public static Response post(String url, String paramName, File value, Map response = Unirest.post(url).headers(headerParam).multiPartContent().field(paramName, new File(value.getAbsolutePath())).asString();
- resp = getResponse(response);
+ resp = getResponse(url, response);
}
return resp;
} catch (Exception e) {
@@ -80,9 +80,9 @@ public static Response post(String url, String paramName, String value, Map response = Unirest.post(url).headers(headerParam).multiPartContent().field(paramName, value).asString();
- resp = getResponse(response);
+ resp = getResponse(url, response);
}
return resp;
} catch (Exception e) {
@@ -96,9 +96,9 @@ public static Response get(String url, String queryParam, Map he
validateRequest(url, headerParam);
String reqUrl = StringUtils.isNotBlank(queryParam) ? url + "?" + queryParam : url;
try {
- while (null == resp && BACKOFF_DELAY <= MAXIMUM_BACKOFF_DELAY) {
+ while (null == resp) {
HttpResponse response = Unirest.get(reqUrl).headers(headerParam).asString();
- resp = getResponse(response);
+ resp = getResponse(reqUrl, response);
}
return resp;
} catch (Exception e) {
@@ -113,19 +113,21 @@ private static void validateRequest(String url, Map headerParam)
throw new ServerException("ERR_INVALID_HEADER_PARAM", "Header Parameter is Missing!");
}
- private static Response getResponse(HttpResponse response) {
+ private static Response getResponse(String url, HttpResponse response) {
Response resp = null;
if (null != response && StringUtils.isNotBlank(response.getBody())) {
try {
resp = mapper.readValue(response.getBody(), Response.class);
BACKOFF_DELAY = INITIAL_BACKOFF_DELAY;
} catch (Exception e) {
- LOGGER.error("UnirestUtil ::: getResponse ::: Error occurred while parsing api response. Error is: "+e.getMessage(), e);
+ LOGGER.error("UnirestUtil ::: getResponse ::: Error occurred while parsing api response for url ::: " + url + ". | Error is: " + e.getMessage(), e);
+ LOGGER.info("UnirestUtil :::: BACKOFF_DELAY ::: " + BACKOFF_DELAY);
if (BACKOFF_DELAY <= MAXIMUM_BACKOFF_DELAY) {
long delay = BACKOFF_DELAY;
BACKOFF_DELAY = BACKOFF_DELAY * INCREMENT_BACKOFF_DELAY;
+ LOGGER.info("UnirestUtil :::: BACKOFF_DELAY after increment::: " + BACKOFF_DELAY);
delay(delay);
- } else throw new ServerException("ERR_API_CALL", "Unable to parse response data! | Error is: " + e.getMessage());
+ } else throw new ServerException("ERR_API_CALL", "Unable to parse response data for url: "+ url +" | Error is: " + e.getMessage());
}
} else {
LOGGER.info("Null Response Received While Making Api Call!");
diff --git a/platform-jobs/samza/distribution/pom.xml b/platform-jobs/samza/distribution/pom.xml
index ab572ff4fa..320006901e 100644
--- a/platform-jobs/samza/distribution/pom.xml
+++ b/platform-jobs/samza/distribution/pom.xml
@@ -95,7 +95,7 @@
org.ekstep
auto-creator
- 0.0.23
+ 0.0.25
tar.gz
distribution