Search in sources :

Example 31 with NonexistentEntityException

use of com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException in project OpenAttestation by OpenAttestation.

the class MwCertificateX509JpaController method edit.

public void edit(MwCertificateX509 mwCertificateX509) throws NonexistentEntityException, Exception {
    EntityManager em = getEntityManager();
    try {
        em.getTransaction().begin();
        mwCertificateX509 = em.merge(mwCertificateX509);
        em.getTransaction().commit();
    } catch (Exception ex) {
        String msg = ex.getLocalizedMessage();
        if (msg == null || msg.length() == 0) {
            Integer id = mwCertificateX509.getId();
            if (findMwCertificateX509(id) == null) {
                throw new NonexistentEntityException("The mwCertificateX509 with id " + id + " no longer exists.");
            }
        }
        throw ex;
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Example 32 with NonexistentEntityException

use of com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException in project OpenAttestation by OpenAttestation.

the class MwKeystoreJpaController method edit.

public void edit(MwKeystore mwKeystore) throws NonexistentEntityException, Exception {
    EntityManager em = getEntityManager();
    try {
        em.getTransaction().begin();
        mwKeystore = em.merge(mwKeystore);
        em.getTransaction().commit();
    } catch (Exception ex) {
        String msg = ex.getLocalizedMessage();
        if (msg == null || msg.length() == 0) {
            Integer id = mwKeystore.getId();
            if (findMwKeystore(id) == null) {
                throw new NonexistentEntityException("The mwKeystore with id " + id + " no longer exists.");
            }
        }
        throw ex;
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Example 33 with NonexistentEntityException

use of com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException in project OpenAttestation by OpenAttestation.

the class MwKeystoreJpaController method destroy.

public void destroy(Integer id) throws NonexistentEntityException {
    EntityManager em = getEntityManager();
    try {
        em.getTransaction().begin();
        MwKeystore mwKeystore;
        try {
            mwKeystore = em.getReference(MwKeystore.class, id);
            mwKeystore.getId();
        } catch (EntityNotFoundException enfe) {
            throw new NonexistentEntityException("The mwKeystore with id " + id + " no longer exists.", enfe);
        }
        em.remove(mwKeystore);
        em.getTransaction().commit();
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) MwKeystore(com.intel.mtwilson.as.data.MwKeystore) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Example 34 with NonexistentEntityException

use of com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException in project OpenAttestation by OpenAttestation.

the class TblModuleManifestLogJpaController method edit.

public void edit(TblModuleManifestLog tblModuleManifestLog) throws NonexistentEntityException, ASDataException {
    EntityManager em = getEntityManager();
    try {
        em.getTransaction().begin();
        TblModuleManifestLog persistentTblModuleManifestLog = em.find(TblModuleManifestLog.class, tblModuleManifestLog.getId());
        TblTaLog taLogIdOld = persistentTblModuleManifestLog.getTaLogId();
        TblTaLog taLogIdNew = tblModuleManifestLog.getTaLogId();
        if (taLogIdNew != null) {
            taLogIdNew = em.getReference(taLogIdNew.getClass(), taLogIdNew.getId());
            tblModuleManifestLog.setTaLogId(taLogIdNew);
        }
        tblModuleManifestLog = em.merge(tblModuleManifestLog);
        if (taLogIdOld != null && !taLogIdOld.equals(taLogIdNew)) {
            taLogIdOld.getTblModuleManifestLogCollection().remove(tblModuleManifestLog);
            taLogIdOld = em.merge(taLogIdOld);
        }
        if (taLogIdNew != null && !taLogIdNew.equals(taLogIdOld)) {
            taLogIdNew.getTblModuleManifestLogCollection().add(tblModuleManifestLog);
            em.merge(taLogIdNew);
        }
        em.getTransaction().commit();
    } catch (Exception ex) {
        String msg = ex.getLocalizedMessage();
        if (msg == null || msg.length() == 0) {
            Integer id = tblModuleManifestLog.getId();
            if (findTblModuleManifestLog(id) == null) {
                throw new NonexistentEntityException("The tblModuleManifestLog with id " + id + " no longer exists.");
            }
        }
        throw new ASDataException(ex);
    } finally {
        em.close();
    }
}
Also used : ASDataException(com.intel.mtwilson.as.controller.exceptions.ASDataException) EntityManager(javax.persistence.EntityManager) TblTaLog(com.intel.mtwilson.as.data.TblTaLog) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) TblModuleManifestLog(com.intel.mtwilson.as.data.TblModuleManifestLog) NoResultException(javax.persistence.NoResultException) ASDataException(com.intel.mtwilson.as.controller.exceptions.ASDataException) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Example 35 with NonexistentEntityException

use of com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException in project OpenAttestation by OpenAttestation.

the class TblOemJpaController method destroy.

public void destroy(Integer id) throws NonexistentEntityException {
    EntityManager em = getEntityManager();
    try {
        em.getTransaction().begin();
        TblOem tblOem;
        try {
            tblOem = em.getReference(TblOem.class, id);
            tblOem.getId();
        } catch (EntityNotFoundException enfe) {
            throw new NonexistentEntityException("The tblOem with id " + id + " no longer exists.", enfe);
        }
        em.remove(tblOem);
        em.getTransaction().commit();
    } finally {
        em.close();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) TblOem(com.intel.mtwilson.as.data.TblOem) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Aggregations

NonexistentEntityException (com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException)40 EntityNotFoundException (javax.persistence.EntityNotFoundException)36 EntityManager (javax.persistence.EntityManager)34 ASDataException (com.intel.mtwilson.as.controller.exceptions.ASDataException)15 IllegalOrphanException (com.intel.mtwilson.as.controller.exceptions.IllegalOrphanException)12 TblMle (com.intel.mtwilson.as.data.TblMle)12 TblModuleManifest (com.intel.mtwilson.as.data.TblModuleManifest)10 NoResultException (javax.persistence.NoResultException)8 TblHosts (com.intel.mtwilson.as.data.TblHosts)6 TblEventType (com.intel.mtwilson.as.data.TblEventType)5 TblHostSpecificManifest (com.intel.mtwilson.as.data.TblHostSpecificManifest)5 TblPackageNamespace (com.intel.mtwilson.as.data.TblPackageNamespace)5 ArrayList (java.util.ArrayList)5 TblPcrManifest (com.intel.mtwilson.as.data.TblPcrManifest)4 TblTaLog (com.intel.mtwilson.as.data.TblTaLog)4 TblSamlAssertion (com.intel.mtwilson.as.data.TblSamlAssertion)3 MwMleSource (com.intel.mtwilson.as.data.MwMleSource)2 TblModuleManifestLog (com.intel.mtwilson.as.data.TblModuleManifestLog)2 ASException (com.intel.mountwilson.as.common.ASException)1 TblMleJpaController (com.intel.mtwilson.as.controller.TblMleJpaController)1