use of com.intel.mtwilson.as.data.TblPcrManifest in project OpenAttestation by OpenAttestation.
the class TblPcrManifestJpaController method edit.
public void edit(TblPcrManifest tblPcrManifest) throws NonexistentEntityException, ASDataException {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
TblPcrManifest persistentTblPcrManifest = em.find(TblPcrManifest.class, tblPcrManifest.getId());
// @since 1.1 we are relying on the audit log for "created on", "created by", etc. type information
/*
TblDbPortalUser updatedByOld = persistentTblPcrManifest.getUpdatedBy();
TblDbPortalUser updatedByNew = tblPcrManifest.getUpdatedBy();
TblDbPortalUser createdByOld = persistentTblPcrManifest.getCreatedBy();
TblDbPortalUser createdByNew = tblPcrManifest.getCreatedBy();
*/
TblMle mleIdOld = persistentTblPcrManifest.getMleId();
TblMle mleIdNew = tblPcrManifest.getMleId();
/*
if (updatedByNew != null) {
updatedByNew = em.getReference(updatedByNew.getClass(), updatedByNew.getId());
tblPcrManifest.setUpdatedBy(updatedByNew);
}
if (createdByNew != null) {
createdByNew = em.getReference(createdByNew.getClass(), createdByNew.getId());
tblPcrManifest.setCreatedBy(createdByNew);
}*/
if (mleIdNew != null) {
mleIdNew = em.getReference(mleIdNew.getClass(), mleIdNew.getId());
tblPcrManifest.setMleId(mleIdNew);
}
tblPcrManifest = em.merge(tblPcrManifest);
/*
if (updatedByOld != null && !updatedByOld.equals(updatedByNew)) {
updatedByOld.getTblPcrManifestCollection().remove(tblPcrManifest);
updatedByOld = em.merge(updatedByOld);
}
if (updatedByNew != null && !updatedByNew.equals(updatedByOld)) {
updatedByNew.getTblPcrManifestCollection().add(tblPcrManifest);
em.merge(updatedByNew);
}
if (createdByOld != null && !createdByOld.equals(createdByNew)) {
createdByOld.getTblPcrManifestCollection().remove(tblPcrManifest);
createdByOld = em.merge(createdByOld);
}
if (createdByNew != null && !createdByNew.equals(createdByOld)) {
createdByNew.getTblPcrManifestCollection().add(tblPcrManifest);
em.merge(createdByNew);
}
*/
if (mleIdOld != null && !mleIdOld.equals(mleIdNew)) {
mleIdOld.getTblPcrManifestCollection().remove(tblPcrManifest);
mleIdOld = em.merge(mleIdOld);
}
if (mleIdNew != null && !mleIdNew.equals(mleIdOld)) {
mleIdNew.getTblPcrManifestCollection().add(tblPcrManifest);
em.merge(mleIdNew);
}
em.getTransaction().commit();
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Integer id = tblPcrManifest.getId();
if (findTblPcrManifest(id) == null) {
throw new NonexistentEntityException("The tblPcrManifest with id " + id + " no longer exists.");
}
}
throw new ASDataException(ex);
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.data.TblPcrManifest in project OpenAttestation by OpenAttestation.
the class ReportsBO method getPcrManifestLog.
public PcrLogReport getPcrManifestLog(TblHosts tblHosts, TblTaLog log, Boolean failureOnly) throws NumberFormatException, IOException {
TblPcrManifest tblPcrManifest = getPcrModuleManifest(tblHosts, log.getMleId(), log.getManifestName());
PcrLogReport manifest = new PcrLogReport();
manifest.setName(Integer.parseInt(log.getManifestName()));
manifest.setValue(log.getManifestValue());
manifest.setVerifiedOn(log.getUpdatedOn());
manifest.setTrustStatus(getTrustStatus(log.getTrustStatus()));
manifest.setWhiteListValue(tblPcrManifest.getValue());
addManifestLogs(tblHosts.getId(), manifest, log, failureOnly, tblPcrManifest);
return manifest;
}
use of com.intel.mtwilson.as.data.TblPcrManifest in project OpenAttestation by OpenAttestation.
the class TblPcrManifestJpaControllerTest method testCreate.
@Test
public void testCreate() {
TblPcrManifest tblPcrManifest = new TblPcrManifest(PcrManifest_ID, "0", "31B97D97B4679917EC3C1D943635693FFBAB4143");
tblPcrManifestJpaController.create(tblPcrManifest);
verify(em).persist(tblPcrManifest);
verify(em).close();
verify(transaction).begin();
verify(transaction).commit();
}
use of com.intel.mtwilson.as.data.TblPcrManifest in project OpenAttestation by OpenAttestation.
the class TblPcrManifestJpaControllerTest method testEdit.
@Test
public void testEdit() throws NonexistentEntityException, ASDataException {
TblPcrManifest tblPcrManifest = new TblPcrManifest(PcrManifest_ID, "0", "31B97D97B4679917EC3C1D943635693FFBAB4143");
doReturn(tblPcrManifest).when(em).find(TblPcrManifest.class, PcrManifest_ID);
doReturn(tblPcrManifest).when(em).getReference(TblOs.class, PcrManifest_ID);
tblPcrManifestJpaController.edit(tblPcrManifest);
verify(em).merge(tblPcrManifest);
verify(em).close();
verify(transaction).begin();
verify(transaction).commit();
}
use of com.intel.mtwilson.as.data.TblPcrManifest in project OpenAttestation by OpenAttestation.
the class PcrGKVStrategyTest method getPcrManifestMap.
private HashMap<String, ? extends IManifest> getPcrManifestMap(TblMle mle) {
HashMap<String, IManifest> pcrManifests = new HashMap<String, IManifest>();
for (TblPcrManifest pcrMf : mle.getTblPcrManifestCollection()) {
pcrMf = pcrManifestJpaController.findPcrManifestById(pcrMf.getId());
pcrManifests.put(pcrMf.getName().trim(), new PcrManifest(Integer.valueOf(pcrMf.getName()), pcrMf.getValue().trim()));
}
return pcrManifests;
}
Aggregations