use of com.intel.mtwilson.as.data.TblPcrManifest in project OpenAttestation by OpenAttestation.
the class TblPcrManifestJpaControllerTest method testDestroy.
@Test
public void testDestroy() throws NonexistentEntityException {
TblPcrManifest tblPcrManifest = new TblPcrManifest(PcrManifest_ID, "0", "31B97D97B4679917EC3C1D943635693FFBAB4143");
doReturn(tblPcrManifest).when(em).getReference(TblPcrManifest.class, PcrManifest_ID);
tblPcrManifestJpaController.destroy(PcrManifest_ID);
verify(em).remove(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 TblMleJpaController method edit.
public void edit(TblMle tblMle) throws IllegalOrphanException, NonexistentEntityException, ASDataException {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
TblMle persistentTblMle = em.find(TblMle.class, tblMle.getId());
Collection<TblHosts> tblHostsCollectionOld = persistentTblMle.getTblHostsCollection();
Collection<TblHosts> tblHostsCollectionNew = tblMle.getTblHostsCollection();
Collection<TblHosts> tblHostsCollection1Old = persistentTblMle.getTblHostsCollection1();
Collection<TblHosts> tblHostsCollection1New = tblMle.getTblHostsCollection1();
Collection<TblPcrManifest> tblPcrManifestCollectionOld = persistentTblMle.getTblPcrManifestCollection();
Collection<TblPcrManifest> tblPcrManifestCollectionNew = tblMle.getTblPcrManifestCollection();
List<String> illegalOrphanMessages = null;
for (TblHosts tblHostsCollectionOldTblHosts : tblHostsCollectionOld) {
if (!tblHostsCollectionNew.contains(tblHostsCollectionOldTblHosts)) {
if (illegalOrphanMessages == null) {
illegalOrphanMessages = new ArrayList<String>();
}
illegalOrphanMessages.add("You must retain TblHosts " + tblHostsCollectionOldTblHosts + " since its vmmMleId field is not nullable.");
}
}
for (TblHosts tblHostsCollection1OldTblHosts : tblHostsCollection1Old) {
if (!tblHostsCollection1New.contains(tblHostsCollection1OldTblHosts)) {
if (illegalOrphanMessages == null) {
illegalOrphanMessages = new ArrayList<String>();
}
illegalOrphanMessages.add("You must retain TblHosts " + tblHostsCollection1OldTblHosts + " since its biosMleId field is not nullable.");
}
}
for (TblPcrManifest tblPcrManifestCollectionOldTblPcrManifest : tblPcrManifestCollectionOld) {
if (!tblPcrManifestCollectionNew.contains(tblPcrManifestCollectionOldTblPcrManifest)) {
if (illegalOrphanMessages == null) {
illegalOrphanMessages = new ArrayList<String>();
}
illegalOrphanMessages.add("You must retain TblPcrManifest " + tblPcrManifestCollectionOldTblPcrManifest + " since its mleId field is not nullable.");
}
}
if (illegalOrphanMessages != null) {
throw new IllegalOrphanException(illegalOrphanMessages);
}
Collection<TblHosts> attachedTblHostsCollectionNew = new ArrayList<TblHosts>();
for (TblHosts tblHostsCollectionNewTblHostsToAttach : tblHostsCollectionNew) {
tblHostsCollectionNewTblHostsToAttach = em.getReference(tblHostsCollectionNewTblHostsToAttach.getClass(), tblHostsCollectionNewTblHostsToAttach.getId());
attachedTblHostsCollectionNew.add(tblHostsCollectionNewTblHostsToAttach);
}
tblHostsCollectionNew = attachedTblHostsCollectionNew;
tblMle.setTblHostsCollection(tblHostsCollectionNew);
Collection<TblHosts> attachedTblHostsCollection1New = new ArrayList<TblHosts>();
for (TblHosts tblHostsCollection1NewTblHostsToAttach : tblHostsCollection1New) {
tblHostsCollection1NewTblHostsToAttach = em.getReference(tblHostsCollection1NewTblHostsToAttach.getClass(), tblHostsCollection1NewTblHostsToAttach.getId());
attachedTblHostsCollection1New.add(tblHostsCollection1NewTblHostsToAttach);
}
tblHostsCollection1New = attachedTblHostsCollection1New;
tblMle.setTblHostsCollection1(tblHostsCollection1New);
Collection<TblPcrManifest> attachedTblPcrManifestCollectionNew = new ArrayList<TblPcrManifest>();
for (TblPcrManifest tblPcrManifestCollectionNewTblPcrManifestToAttach : tblPcrManifestCollectionNew) {
tblPcrManifestCollectionNewTblPcrManifestToAttach = em.getReference(tblPcrManifestCollectionNewTblPcrManifestToAttach.getClass(), tblPcrManifestCollectionNewTblPcrManifestToAttach.getId());
attachedTblPcrManifestCollectionNew.add(tblPcrManifestCollectionNewTblPcrManifestToAttach);
}
tblPcrManifestCollectionNew = attachedTblPcrManifestCollectionNew;
tblMle.setTblPcrManifestCollection(tblPcrManifestCollectionNew);
tblMle = em.merge(tblMle);
for (TblHosts tblHostsCollectionNewTblHosts : tblHostsCollectionNew) {
if (!tblHostsCollectionOld.contains(tblHostsCollectionNewTblHosts)) {
TblMle oldVmmMleIdOfTblHostsCollectionNewTblHosts = tblHostsCollectionNewTblHosts.getVmmMleId();
tblHostsCollectionNewTblHosts.setVmmMleId(tblMle);
tblHostsCollectionNewTblHosts = em.merge(tblHostsCollectionNewTblHosts);
if (oldVmmMleIdOfTblHostsCollectionNewTblHosts != null && !oldVmmMleIdOfTblHostsCollectionNewTblHosts.equals(tblMle)) {
oldVmmMleIdOfTblHostsCollectionNewTblHosts.getTblHostsCollection().remove(tblHostsCollectionNewTblHosts);
em.merge(oldVmmMleIdOfTblHostsCollectionNewTblHosts);
}
}
}
for (TblHosts tblHostsCollection1NewTblHosts : tblHostsCollection1New) {
if (!tblHostsCollection1Old.contains(tblHostsCollection1NewTblHosts)) {
TblMle oldBiosMleIdOfTblHostsCollection1NewTblHosts = tblHostsCollection1NewTblHosts.getBiosMleId();
tblHostsCollection1NewTblHosts.setBiosMleId(tblMle);
tblHostsCollection1NewTblHosts = em.merge(tblHostsCollection1NewTblHosts);
if (oldBiosMleIdOfTblHostsCollection1NewTblHosts != null && !oldBiosMleIdOfTblHostsCollection1NewTblHosts.equals(tblMle)) {
oldBiosMleIdOfTblHostsCollection1NewTblHosts.getTblHostsCollection1().remove(tblHostsCollection1NewTblHosts);
em.merge(oldBiosMleIdOfTblHostsCollection1NewTblHosts);
}
}
}
for (TblPcrManifest tblPcrManifestCollectionNewTblPcrManifest : tblPcrManifestCollectionNew) {
if (!tblPcrManifestCollectionOld.contains(tblPcrManifestCollectionNewTblPcrManifest)) {
TblMle oldMleIdOfTblPcrManifestCollectionNewTblPcrManifest = tblPcrManifestCollectionNewTblPcrManifest.getMleId();
tblPcrManifestCollectionNewTblPcrManifest.setMleId(tblMle);
tblPcrManifestCollectionNewTblPcrManifest = em.merge(tblPcrManifestCollectionNewTblPcrManifest);
if (oldMleIdOfTblPcrManifestCollectionNewTblPcrManifest != null && !oldMleIdOfTblPcrManifestCollectionNewTblPcrManifest.equals(tblMle)) {
oldMleIdOfTblPcrManifestCollectionNewTblPcrManifest.getTblPcrManifestCollection().remove(tblPcrManifestCollectionNewTblPcrManifest);
em.merge(oldMleIdOfTblPcrManifestCollectionNewTblPcrManifest);
}
}
}
em.getTransaction().commit();
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Integer id = tblMle.getId();
if (findTblMle(id) == null) {
throw new NonexistentEntityException("The tblMle 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 TblPcrManifestJpaController method findByMleIdName.
/**
* Added By: Sudhir on June 20, 2012
*
* This method checks if the specified pcr entry already exists for the MLE.
* @param id: Identity of the MLE
* @param pcrName: Name of the PCR
* @return : Single row result if there is a match or else null.
*/
public TblPcrManifest findByMleIdName(Integer id, String pcrName) {
EntityManager em = getEntityManager();
try {
Query query = em.createNamedQuery("TblPcrManifest.findByMleIdName");
query.setParameter("mleId", id);
query.setParameter("name", pcrName);
query.setHint(QueryHints.REFRESH, HintValues.TRUE);
query.setHint(QueryHints.CACHE_USAGE, CacheUsage.DoNotCheckCache);
TblPcrManifest pcrManifest = (TblPcrManifest) query.getSingleResult();
return pcrManifest;
} catch (NoResultException e) {
log.error(String.format("PCR Manifest for MLE %d PCR# not found in Database ", id, pcrName));
return null;
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.data.TblPcrManifest in project OpenAttestation by OpenAttestation.
the class HostBOTest method mockGetHost.
public TblHosts mockGetHost() {
TblHosts tblHosts = new TblHosts();
tblHosts.setId(1);
tblHosts.setName(SERVER_NAME);
tblHosts.setIPAddress(SERVER_NAME);
String biosName = "DELL";
String biosVersion = "A08";
String oemName = "DELL";
TblMle biosMle = new TblMle();
biosMle.setId(1);
biosMle.setName(biosName);
biosMle.setVersion(biosVersion);
TblOem oem = new TblOem();
oem.setId(1);
oem.setName(oemName);
biosMle.setOemId(oem);
Collection<TblPcrManifest> tblPcrManifestCollection = new ArrayList<TblPcrManifest>();
TblPcrManifest tblPcrManifest = new TblPcrManifest();
tblPcrManifest.setId(1);
tblPcrManifest.setName("0");
tblPcrManifest.setValue("31B97D97B4679917EC3C1D943635693FFBAB4143");
tblPcrManifestCollection.add(tblPcrManifest);
biosMle.setTblPcrManifestCollection(tblPcrManifestCollection);
tblHosts.setBiosMleId(biosMle);
String vmmName = "XEN";
String vmmVersion = "4.3";
String osName = "Fedora";
String osVersion = "20";
TblMle vmmMle = new TblMle();
vmmMle.setId(1);
vmmMle.setName(vmmName);
vmmMle.setVersion(vmmVersion);
TblOs os = new TblOs();
os.setId(1);
os.setName(osName);
os.setVersion(osVersion);
vmmMle.setOsId(os);
Collection<TblPcrManifest> tblPcrManifestCollectionVMM = new ArrayList<TblPcrManifest>();
TblPcrManifest tblPcrManifestVMM = new TblPcrManifest();
tblPcrManifestVMM.setId(2);
tblPcrManifestVMM.setName("18");
tblPcrManifestVMM.setValue("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
tblPcrManifestCollection.add(tblPcrManifestVMM);
vmmMle.setTblPcrManifestCollection(tblPcrManifestCollectionVMM);
tblHosts.setVmmMleId(vmmMle);
tblHosts.setTlsPolicyName("");
tblHosts.setPort(8181);
return tblHosts;
}
use of com.intel.mtwilson.as.data.TblPcrManifest in project OpenAttestation by OpenAttestation.
the class ReportsBOTest method mockFindByName.
public TblHosts mockFindByName() {
TblHosts tblHosts = new TblHosts();
tblHosts.setId(1);
tblHosts.setName(SERVER_NAME);
tblHosts.setIPAddress(SERVER_NAME);
String biosName = "DELL";
String biosVersion = "A08";
String oemName = "DELL";
TblMle biosMle = new TblMle();
biosMle.setId(1);
biosMle.setName(biosName);
biosMle.setVersion(biosVersion);
TblOem oem = new TblOem();
oem.setId(1);
oem.setName(oemName);
biosMle.setOemId(oem);
Collection<TblPcrManifest> tblPcrManifestCollection = new ArrayList<TblPcrManifest>();
TblPcrManifest tblPcrManifest = new TblPcrManifest();
tblPcrManifest.setId(1);
tblPcrManifest.setName("0");
tblPcrManifest.setValue("31B97D97B4679917EC3C1D943635693FFBAB4143");
tblPcrManifestCollection.add(tblPcrManifest);
biosMle.setTblPcrManifestCollection(tblPcrManifestCollection);
tblHosts.setBiosMleId(biosMle);
String vmmName = "XEN";
String vmmVersion = "4.3";
String osName = "Fedora";
String osVersion = "20";
TblMle vmmMle = new TblMle();
vmmMle.setId(1);
vmmMle.setName(vmmName);
vmmMle.setVersion(vmmVersion);
TblOs os = new TblOs();
os.setId(1);
os.setName(osName);
os.setVersion(osVersion);
vmmMle.setOsId(os);
Collection<TblPcrManifest> tblPcrManifestCollectionVMM = new ArrayList<TblPcrManifest>();
TblPcrManifest tblPcrManifestVMM = new TblPcrManifest();
tblPcrManifestVMM.setId(2);
tblPcrManifestVMM.setName("18");
tblPcrManifestVMM.setValue("FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF");
tblPcrManifestCollectionVMM.add(tblPcrManifestVMM);
vmmMle.setTblPcrManifestCollection(tblPcrManifestCollectionVMM);
tblHosts.setVmmMleId(vmmMle);
return tblHosts;
}
Aggregations