Skip to content

Commit

Permalink
Address Lift findings
Browse files Browse the repository at this point in the history
Signed-off-by: nscuro <[email protected]>
  • Loading branch information
nscuro committed Mar 26, 2023
1 parent 81b888e commit 2a101f9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public ArrayNode getDojoTestIds(final String token, final String eid) {
if (jsonObject != null) {
final ArrayNode dojoArray = Jackson.optArray(jsonObject, "results", Jackson.newArray());
String nextUrl;
while (jsonObject.get("next") != null) {
while (jsonObject != null && jsonObject.get("next") != null) {
nextUrl = jsonObject.get("next").toString();
LOGGER.debug("Making the subsequent pagination call on " + nextUrl);
uriBuilder = new URIBuilder(nextUrl);
Expand All @@ -113,7 +113,9 @@ public ArrayNode getDojoTestIds(final String token, final String eid) {
try (CloseableHttpResponse response1 = HttpClientPool.getClient().execute(request)) {
nextUrl = jsonObject.get("next").toString();
jsonObject = Jackson.readHttpResponse(response1);
dojoArray.addAll(Jackson.optArray(jsonObject, "results", Jackson.newArray()));
if (jsonObject != null) {
dojoArray.addAll(Jackson.optArray(jsonObject, "results", Jackson.newArray()));
}
}
}
LOGGER.debug("Successfully retrieved the test list ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public InputStream process() {
kdi.process(project, externalId.getPropertyValue());
}
}
return new ByteArrayInputStream(Jackson.toString(kdi.generate()).getBytes());
return new ByteArrayInputStream(Jackson.toString(kdi.generate()).getBytes(StandardCharsets.UTF_8));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,17 +76,19 @@ public MetaModel analyze(final Component component) {
try (final CloseableHttpResponse response = processHttpRequest(url)) {
if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
JsonNode jsonObject = Jackson.readHttpResponse(response);
final String latest = Jackson.optString(jsonObject, "version", null);
if (latest != null) {
meta.setLatestVersion(latest);
}
final String published = Jackson.optString(jsonObject, "date");
if (!published.isBlank()) {
final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
try {
meta.setPublishedTimestamp(dateFormat.parse(published));
} catch (ParseException e) {
LOGGER.warn("An error occurred while parsing upload time", e);
if (jsonObject != null) {
final String latest = Jackson.optString(jsonObject, "version", null);
if (latest != null) {
meta.setLatestVersion(latest);
}
final String published = Jackson.optString(jsonObject, "date");
if (!published.isBlank()) {
final DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
try {
meta.setPublishedTimestamp(dateFormat.parse(published));
} catch (ParseException e) {
LOGGER.warn("An error occurred while parsing upload time", e);
}
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,12 @@ private void handle(final Component component, final JsonNode object) {
String purl = null;
final JsonNode metaInfo = object.get("meta");
if (metaInfo != null) {
purl = Jackson.optString(metaInfo.get("package"), "url");
if (purl == null) {
purl = component.getPurlCoordinates().toString();
final JsonNode pkg = metaInfo.get("package");
if (pkg != null) {
purl = Jackson.optString(pkg, "url");
if (purl == null) {
purl = component.getPurlCoordinates().toString();
}
}
}
final ArrayNode data = Jackson.optArray(object, "data");
Expand Down

0 comments on commit 2a101f9

Please sign in to comment.