use of com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException in project OpenAttestation by OpenAttestation.
the class TblHostsJpaController method edit.
public void edit(TblHosts tblHosts) throws IllegalOrphanException, NonexistentEntityException, ASDataException {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
TblHosts persistentTblHosts = em.find(TblHosts.class, tblHosts.getId());
TblMle vmmMleIdOld = persistentTblHosts.getVmmMleId();
TblMle vmmMleIdNew = tblHosts.getVmmMleId();
TblMle biosMleIdOld = persistentTblHosts.getBiosMleId();
TblMle biosMleIdNew = tblHosts.getBiosMleId();
if (vmmMleIdNew != null) {
vmmMleIdNew = em.getReference(vmmMleIdNew.getClass(), vmmMleIdNew.getId());
tblHosts.setVmmMleId(vmmMleIdNew);
}
if (biosMleIdNew != null) {
biosMleIdNew = em.getReference(biosMleIdNew.getClass(), biosMleIdNew.getId());
tblHosts.setBiosMleId(biosMleIdNew);
}
// encrypt addon connection string, persist, then restore the plaintext
String addOnConnectionString = tblHosts.getAddOnConnectionInfo();
if (addOnConnectionString != null) {
tblHosts = em.merge(tblHosts);
} else {
tblHosts = em.merge(tblHosts);
}
if (vmmMleIdOld != null && !vmmMleIdOld.equals(vmmMleIdNew)) {
vmmMleIdOld.getTblHostsCollection().remove(tblHosts);
vmmMleIdOld = em.merge(vmmMleIdOld);
}
if (vmmMleIdNew != null && !vmmMleIdNew.equals(vmmMleIdOld)) {
vmmMleIdNew.getTblHostsCollection().add(tblHosts);
em.merge(vmmMleIdNew);
}
if (biosMleIdOld != null && !biosMleIdOld.equals(biosMleIdNew)) {
biosMleIdOld.getTblHostsCollection().remove(tblHosts);
biosMleIdOld = em.merge(biosMleIdOld);
}
if (biosMleIdNew != null && !biosMleIdNew.equals(biosMleIdOld)) {
biosMleIdNew.getTblHostsCollection().add(tblHosts);
em.merge(biosMleIdNew);
}
em.getTransaction().commit();
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Integer id = tblHosts.getId();
if (findTblHosts(id) == null) {
throw new NonexistentEntityException("The tblHosts with id " + id + " no longer exists.");
}
}
throw new ASDataException(ex);
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException in project OpenAttestation by OpenAttestation.
the class TblLocationPcrJpaController method destroy.
public void destroy(Integer id) throws NonexistentEntityException {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
TblLocationPcr tblLocationPcr;
try {
tblLocationPcr = em.getReference(TblLocationPcr.class, id);
tblLocationPcr.getId();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException("The tblLocationPcr with id " + id + " no longer exists.", enfe);
}
em.remove(tblLocationPcr);
em.getTransaction().commit();
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException 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.controller.exceptions.NonexistentEntityException in project OpenAttestation by OpenAttestation.
the class TblRequestQueueJpaController method edit.
public void edit(TblRequestQueue tblRequestQueue) throws NonexistentEntityException, ASDataException {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
em.merge(tblRequestQueue);
em.getTransaction().commit();
} catch (Exception ex) {
String msg = ex.getLocalizedMessage();
if (msg == null || msg.length() == 0) {
Integer id = tblRequestQueue.getId();
if (findTblRequestQueue(id) == null) {
throw new NonexistentEntityException("The tblRequestQueue with id " + id + " no longer exists.");
}
}
throw new ASDataException(ex);
} finally {
em.close();
}
}
use of com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException in project OpenAttestation by OpenAttestation.
the class TblSamlAssertionJpaController method destroy.
public void destroy(Integer id) throws NonexistentEntityException {
EntityManager em = getEntityManager();
try {
em.getTransaction().begin();
TblSamlAssertion tblSamlAssertion;
try {
tblSamlAssertion = em.getReference(TblSamlAssertion.class, id);
tblSamlAssertion.getId();
} catch (EntityNotFoundException enfe) {
throw new NonexistentEntityException("The tblSamlAssertion with id " + id + " no longer exists.", enfe);
}
TblHosts hostId = tblSamlAssertion.getHostId();
if (hostId != null) {
hostId.getTblSamlAssertionCollection().remove(tblSamlAssertion);
em.merge(hostId);
}
em.remove(tblSamlAssertion);
em.getTransaction().commit();
} finally {
em.close();
}
}
Aggregations