use of uk.nhs.digital.website.beans.ThreatIds in project hippo by NHS-digital-website.
the class CyberAlertResource method fetchAllThreatIds.
@GET
@Path("/getAllThreatIds/")
public ThreatIds fetchAllThreatIds(@Context HttpServletRequest request, @Context HttpServletResponse servletResponse) {
ThreatIds threatId = new ThreatIds();
List<ThreatIdDate> threatIdDateList = new ArrayList<ThreatIdDate>();
try {
final HstQuery query = createQuery(new DefaultRestContext(this, request), CyberAlert.class, Subtypes.INCLUDE);
query.setLimit(100);
final HstQueryResult result = query.execute();
HippoBeanIterator iterator = result.getHippoBeans();
while (iterator.hasNext()) {
CyberAlert cyberAlert = (CyberAlert) iterator.nextHippoBean();
List<Calendar> calList = new ArrayList<Calendar>();
ThreatIdDate threDate = new ThreatIdDate();
if (cyberAlert != null) {
List<HippoBean> cyberAcknowledgementList = (List<HippoBean>) cyberAlert.getCyberAcknowledgements();
for (HippoBean cyberAckn : cyberAcknowledgementList) {
if (cyberAckn instanceof CyberAcknowledgement) {
CyberAcknowledgement cybAck = (CyberAcknowledgement) cyberAckn;
calList.add(cybAck.getResponseDatetime());
}
}
threDate.setResponsedates(calList);
threDate.setThreatid(cyberAlert.getThreatId());
}
threatIdDateList.add(threDate);
}
} catch (Exception e) {
log.error("Error finding beans", e);
}
threatId.setThreatids(threatIdDateList);
return threatId;
}
Aggregations