use of com.intel.mtwilson.as.data.TblTaLog in project OpenAttestation by OpenAttestation.
the class TblTaLogJpaController method destroy.
public void destroy(Integer id) throws IllegalOrphanException, NonexistentEntityException {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
TblTaLog tblTaLog;
try {
tblTaLog = em.getReference(TblTaLog.class, id);
tblTaLog.getId();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException("The tblTaLog with id " + id + " no longer exists.", enfe);
}
em.remove(tblTaLog);
em.getTransaction().commit();
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.data.TblTaLog in project OpenAttestation by OpenAttestation.
the class TblTaLogJpaController method getTblTaLogCount.
public int getTblTaLogCount() {
EntityManager em = getEntityManager();
try {
CriteriaQuery cq = em.getCriteriaBuilder().createQuery();
Root<TblTaLog> rt = cq.from(TblTaLog.class);
cq.select(em.getCriteriaBuilder().count(rt));
Query q = em.createQuery(cq);
return ((Long) q.getSingleResult()).intValue();
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.data.TblTaLog in project OpenAttestation by OpenAttestation.
the class TblTaLogJpaController method getHostTALogEntryBefore.
public TblTaLog getHostTALogEntryBefore(int hostId, Date expiryTime) {
EntityManager em = getEntityManager();
try {
Query query = em.createNamedQuery("TblTaLog.getHostTALogEntryBefore");
query.setParameter("hostId", hostId);
query.setParameter("expiryTs", expiryTime);
List<TblTaLog> logs = query.getResultList();
if (logs != null && logs.size() > 0) {
return logs.get(0);
}
} finally {
em.close();
}
return null;
}
use of com.intel.mtwilson.as.data.TblTaLog in project OpenAttestation by OpenAttestation.
the class HostBO method deleteTALogs.
private void deleteTALogs(Integer hostId) throws IllegalOrphanException {
TblTaLogJpaController tblTaLogJpaController = getTaLogJpaController();
List<TblTaLog> taLogs = tblTaLogJpaController.findLogsByHostId(hostId, new Date());
if (taLogs != null) {
for (TblTaLog taLog : taLogs) {
try {
tblTaLogJpaController.destroy(taLog.getId());
} catch (NonexistentEntityException e) {
log.warn("Ta Log is already deleted " + taLog.getId());
}
}
log.info("Deleted all the logs for the given host " + hostId);
}
}
use of com.intel.mtwilson.as.data.TblTaLog in project OpenAttestation by OpenAttestation.
the class HostTrustBO method logBlankTrustStatus.
/*Bug 510
* Added to support removal of TPM from host which was previously enabled.
* Adding blank row to ta log table will prevent an invalid trust report
*/
private void logBlankTrustStatus(TblHosts host) {
Date today = new Date(System.currentTimeMillis());
TblTaLog taLog = new TblTaLog();
taLog.setHostID(host.getId());
taLog.setMleId(0);
taLog.setTrustStatus(false);
taLog.setManifestName("");
taLog.setManifestValue("");
taLog.setUpdatedOn(today);
new TblTaLogJpaController(getEntityManagerFactory()).create(taLog);
}
Aggregations