use of com.intel.mountwilson.as.hostmanifestreport.data.HostManifestReportType in project OpenAttestation by OpenAttestation.
the class ReportsBO method getReportManifest.
public HostManifestReportType getReportManifest(Hostname hostName) {
// datatype.Hostname
HostManifestReportType hostManifestReportType = new HostManifestReportType();
/*
* if (hostName == null || hostName.isEmpty()) { throw new
* ASException(ErrorCode.VALIDATION_ERROR, "Input Hostname " + hostName
* + " is empty."); }
*
*/
TblHosts tblHosts = null;
try {
// datatype.Hostname
tblHosts = getTblHostsJpaController().findByName(hostName.toString());
} catch (CryptographyException e) {
throw new ASException(e, ErrorCode.AS_ENCRYPTION_ERROR, e.getCause() == null ? e.getMessage() : e.getCause().getMessage());
}
if (tblHosts == null) {
throw new ASException(ErrorCode.AS_HOST_NOT_FOUND, hostName.toString());
}
Date lastStatusTs = getTblTaLogJpaController().findLastStatusTs(tblHosts.getId());
if (lastStatusTs != null) {
List<TblTaLog> logs = getTblTaLogJpaController().findLogsByHostId(tblHosts.getId(), lastStatusTs);
com.intel.mountwilson.as.hostmanifestreport.data.HostType hostType = new com.intel.mountwilson.as.hostmanifestreport.data.HostType();
// datatype.Hostname
hostType.setName(hostName.toString());
if (logs != null) {
for (TblTaLog log : logs) {
ManifestType manifest = new ManifestType();
manifest.setName(Integer.parseInt(log.getManifestName()));
manifest.setValue(log.getManifestValue());
manifest.setVerifiedOn(Util.getCalendar(log.getUpdatedOn()));
manifest.setTrustStatus(getTrustStatus(log.getTrustStatus()));
hostType.getManifest().add(manifest);
}
}
hostManifestReportType.setHost(hostType);
}
return hostManifestReportType;
}
use of com.intel.mountwilson.as.hostmanifestreport.data.HostManifestReportType in project OpenAttestation by OpenAttestation.
the class ApiClient method getHostManifestReport.
@Override
public HostManifestReportType getHostManifestReport(Hostname hostname) throws IOException, ApiException, SignatureException, JAXBException {
MultivaluedMap<String, String> query = new MultivaluedMapImpl();
query.add("hostName", hostname.toString());
HostManifestReportType report = fromXML(httpGet(asurl("/hosts/reports/trust", query)), HostManifestReportType.class);
return report;
}
use of com.intel.mountwilson.as.hostmanifestreport.data.HostManifestReportType in project OpenAttestation by OpenAttestation.
the class ReportsBOTest method testGetReportManifest.
@Test
public void testGetReportManifest() {
when(tblHostsJpaController.findByName(anyString())).thenReturn(mockFindByName());
when(tblTaLogJpaController.findLastStatusTs(any(Integer.class))).thenReturn(new Date());
List<TblTaLog> taLogs = new ArrayList<TblTaLog>();
taLogs.add(new TblTaLog(Integer.valueOf(1), 1, 1, "0", "31B97D97B4679917EC3C1D943635693FFBAB4143", true, new Date()));
when(tblTaLogJpaController.findLogsByHostId(anyInt(), any(Date.class))).thenReturn(taLogs);
HostManifestReportType hostManifestReportType = reportsBO.getReportManifest(new Hostname(SERVER_NAME));
assertNotNull(hostManifestReportType);
assertNotNull(hostManifestReportType.getHost());
}
Aggregations