Search in sources :

Example 1 with ManifestType

use of com.intel.mountwilson.as.hostmanifestreport.data.ManifestType 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)

Aggregations

ASException (com.intel.mountwilson.as.common.ASException)1 HostManifestReportType (com.intel.mountwilson.as.hostmanifestreport.data.HostManifestReportType)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 TblTaLog (com.intel.mtwilson.as.data.TblTaLog)1 CryptographyException (com.intel.mtwilson.crypto.CryptographyException)1