Add ACA address as option 3rd commandline parameter. Handle case where no reports are available or selected for download.

This commit is contained in:
chubtub 2021-03-16 10:16:17 -04:00
parent 7064c00c0b
commit 175d2238d2
2 changed files with 15 additions and 4 deletions
HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers
scripts

View File

@ -193,7 +193,8 @@ public class ValidationReportsPageController extends PageController<NoPageParams
} }
break; break;
case "createTimes": case "createTimes":
if (!parameterValue.equals(UNDEFINED)) { if (!parameterValue.equals(UNDEFINED)
&& !parameterValue.isEmpty()) {
String[] timestamps = parameterValue.split(","); String[] timestamps = parameterValue.split(",");
for (String timestamp : timestamps) { for (String timestamp : timestamps) {
createTimes.add(LocalDateTime.parse(timestamp, createTimes.add(LocalDateTime.parse(timestamp,
@ -202,7 +203,8 @@ public class ValidationReportsPageController extends PageController<NoPageParams
} }
break; break;
case "deviceNames": case "deviceNames":
if (!parameterValue.equals(UNDEFINED)) { if (!parameterValue.equals(UNDEFINED)
&& !parameterValue.isEmpty()) {
deviceNames = parameterValue.split(","); deviceNames = parameterValue.split(",");
} }
break; break;
@ -240,9 +242,11 @@ public class ValidationReportsPageController extends PageController<NoPageParams
reportData.deleteCharAt(reportData.length() - 1); reportData.deleteCharAt(reportData.length() - 1);
reportData.append("\n,,,,,"); reportData.append("\n,,,,,");
} }
} if (reportData.lastIndexOf(",") > 4) {
reportData.delete(reportData.lastIndexOf(",") - 4, reportData.length()); reportData.delete(reportData.lastIndexOf(",") - 4, reportData.length());
} }
}
}
bufferedWriter.append(columnHeaders + "\n"); bufferedWriter.append(columnHeaders + "\n");
bufferedWriter.append(reportData.toString() + "\n"); bufferedWriter.append(reportData.toString() + "\n");
LOGGER.info(columnHeaders); LOGGER.info(columnHeaders);

View File

@ -3,8 +3,15 @@
#User input parameters: #User input parameters:
#$1 filter start date 'yyyy-mm-dd' #$1 filter start date 'yyyy-mm-dd'
#$2 filter end date 'yyyy-mm-dd' #$2 filter end date 'yyyy-mm-dd'
#$3 ACA address, default is localhost if not given
endpoint="https://localhost:8443/HIRS_AttestationCAPortal/portal/validation-reports" if [ -z "$3" ]
then
endpoint="https://localhost:8443/HIRS_AttestationCAPortal/portal/validation-reports"
else
endpoint="https://$3:8443/HIRS_AttestationCAPortal/portal/validation-reports"
fi
echo "$endpoint"
content=$(curl --insecure $endpoint/list) content=$(curl --insecure $endpoint/list)
rawTimes=$(jq -r '.data | map(.createTime | tostring) | join(",")' <<< "$content") rawTimes=$(jq -r '.data | map(.createTime | tostring) | join(",")' <<< "$content")
createTimes="" createTimes=""