Search in sources :

Example 1 with HostManifestReportType

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;
}
Also used : ManifestType(com.intel.mountwilson.as.hostmanifestreport.data.ManifestType) TblTaLog(com.intel.mtwilson.as.data.TblTaLog) HostManifestReportType(com.intel.mountwilson.as.hostmanifestreport.data.HostManifestReportType) HostType(com.intel.mountwilson.as.hosttrustreport.data.HostType) CryptographyException(com.intel.mtwilson.crypto.CryptographyException) TblHosts(com.intel.mtwilson.as.data.TblHosts) ASException(com.intel.mountwilson.as.common.ASException)

Example 2 with 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;
}
Also used : HostManifestReportType(com.intel.mountwilson.as.hostmanifestreport.data.HostManifestReportType)

Example 3 with HostManifestReportType

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());
}
Also used : TblTaLog(com.intel.mtwilson.as.data.TblTaLog) ArrayList(java.util.ArrayList) Hostname(com.intel.mtwilson.util.net.Hostname) HostManifestReportType(com.intel.mountwilson.as.hostmanifestreport.data.HostManifestReportType) Date(java.util.Date) Test(org.junit.Test)

Aggregations

HostManifestReportType (com.intel.mountwilson.as.hostmanifestreport.data.HostManifestReportType)3 TblTaLog (com.intel.mtwilson.as.data.TblTaLog)2 ASException (com.intel.mountwilson.as.common.ASException)1 ManifestType (com.intel.mountwilson.as.hostmanifestreport.data.ManifestType)1 HostType (com.intel.mountwilson.as.hosttrustreport.data.HostType)1 TblHosts (com.intel.mtwilson.as.data.TblHosts)1 CryptographyException (com.intel.mtwilson.crypto.CryptographyException)1 Hostname (com.intel.mtwilson.util.net.Hostname)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Test (org.junit.Test)1