Search in sources :

Example 6 with TblTaLog

use of com.intel.mtwilson.as.data.TblTaLog in project OpenAttestation by OpenAttestation.

the class HostBOTest method testDeleteHost.

@Test
public void testDeleteHost() throws CryptographyException {
    List<TblTaLog> taLogs = new ArrayList<TblTaLog>();
    taLogs.add(new TblTaLog(1));
    taLogs.add(new TblTaLog(2));
    when(taLogJpaController.findLogsByHostId(anyInt(), any(Date.class))).thenReturn(taLogs);
    doReturn(new TblHosts(1)).when(hostBO).getHostByName(new Hostname(SERVER_NAME));
    String response = hostBO.deleteHost(new Hostname(SERVER_NAME));
    assertTrue(response.equalsIgnoreCase("true"));
}
Also used : TblTaLog(com.intel.mtwilson.as.data.TblTaLog) TblHosts(com.intel.mtwilson.as.data.TblHosts) ArrayList(java.util.ArrayList) Hostname(com.intel.mtwilson.util.net.Hostname) Matchers.anyString(org.mockito.Matchers.anyString) Date(java.util.Date) Test(org.junit.Test)

Example 7 with TblTaLog

use of com.intel.mtwilson.as.data.TblTaLog in project OpenAttestation by OpenAttestation.

the class HostTrustBO method logTrustStatus.

private void logTrustStatus(TblHosts host, TblMle mle, IManifest manifest) {
    Date today = new Date(System.currentTimeMillis());
    PcrManifest pcrManifest = (PcrManifest) manifest;
    TblTaLog taLog = new TblTaLog();
    taLog.setHostID(host.getId());
    taLog.setMleId(mle.getId());
    taLog.setManifestName(String.valueOf(pcrManifest.getPcrNumber()));
    taLog.setManifestValue(pcrManifest.getPcrValue());
    taLog.setTrustStatus(pcrManifest.getVerifyStatus());
    taLog.setUpdatedOn(today);
    getTblTaLogJpaController().create(taLog);
}
Also used : TblTaLog(com.intel.mtwilson.as.data.TblTaLog) PcrManifest(com.intel.mountwilson.manifest.data.PcrManifest) Date(java.util.Date)

Example 8 with TblTaLog

use of com.intel.mtwilson.as.data.TblTaLog in project OpenAttestation by OpenAttestation.

the class TblTaLogJpaController method findLastStatusTs.

public Date findLastStatusTs(Integer hostId) {
    Date lastUpdateTs = null;
    EntityManager em = getEntityManager();
    try {
        Query query = em.createNamedQuery("TblTaLog.findLastStatusTs");
        query.setParameter("hostID", hostId);
        query.setMaxResults(1);
        List<TblTaLog> logs = query.getResultList();
        if (logs != null && logs.size() == 1)
            lastUpdateTs = logs.get(0).getUpdatedOn();
    } finally {
        em.close();
    }
    return lastUpdateTs;
}
Also used : EntityManager(javax.persistence.EntityManager) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Query(javax.persistence.Query) TblTaLog(com.intel.mtwilson.as.data.TblTaLog) Date(java.util.Date)

Example 9 with TblTaLog

use of com.intel.mtwilson.as.data.TblTaLog in project OpenAttestation by OpenAttestation.

the class TblTaLogJpaController method findLogsByHostId.

public List<TblTaLog> findLogsByHostId(int hostId) {
    EntityManager em = getEntityManager();
    try {
        Query query = em.createNamedQuery("TblTaLog.findLogsByHostId2");
        query.setParameter("hostID", hostId);
        List<TblTaLog> logs = query.getResultList();
        return logs;
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Query(javax.persistence.Query) TblTaLog(com.intel.mtwilson.as.data.TblTaLog)

Example 10 with TblTaLog

use of com.intel.mtwilson.as.data.TblTaLog in project OpenAttestation by OpenAttestation.

the class TblTaLogJpaController method findTrustStatusByHostId.

// Custom find methods
public List<TblTaLog> findTrustStatusByHostId(int hostId, int maxresults) {
    EntityManager em = getEntityManager();
    try {
        Query query = em.createNamedQuery("TblTaLog.findTrustStatusByHostId");
        query.setParameter("hostID", hostId);
        query.setMaxResults(maxresults);
        List<TblTaLog> logs = query.getResultList();
        return logs;
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) CriteriaQuery(javax.persistence.criteria.CriteriaQuery) Query(javax.persistence.Query) TblTaLog(com.intel.mtwilson.as.data.TblTaLog)

Aggregations

TblTaLog (com.intel.mtwilson.as.data.TblTaLog)23 EntityManager (javax.persistence.EntityManager)11 Date (java.util.Date)9 Query (javax.persistence.Query)7 CriteriaQuery (javax.persistence.criteria.CriteriaQuery)7 Hostname (com.intel.mtwilson.util.net.Hostname)6 TblHosts (com.intel.mtwilson.as.data.TblHosts)5 ASException (com.intel.mountwilson.as.common.ASException)4 NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)4 CryptographyException (com.intel.mtwilson.crypto.CryptographyException)4 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 HostType (com.intel.mountwilson.as.hosttrustreport.data.HostType)3 TblTaLogJpaController (com.intel.mtwilson.as.controller.TblTaLogJpaController)3 EntityNotFoundException (javax.persistence.EntityNotFoundException)3 HostManifestReportType (com.intel.mountwilson.as.hostmanifestreport.data.HostManifestReportType)2 HostsTrustReportType (com.intel.mountwilson.as.hosttrustreport.data.HostsTrustReportType)2 TblModuleManifestLog (com.intel.mtwilson.as.data.TblModuleManifestLog)2 IOException (java.io.IOException)2 ManifestType (com.intel.mountwilson.as.hostmanifestreport.data.ManifestType)1