Search in sources :

Example 36 with NonexistentEntityException

use of com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException 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();
    }
}
Also used : EntityManager(javax.persistence.EntityManager) TblTaLog(com.intel.mtwilson.as.data.TblTaLog) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Example 37 with NonexistentEntityException

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

the class TblRequestQueueJpaController method destroy.

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

Example 38 with NonexistentEntityException

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

the class HostBO method deleteModulesForMLE.

private void deleteModulesForMLE(TxtHostRecord host) throws NonexistentEntityException, IOException {
    TblMleJpaController tblMleJpaController = getMleJpaController();
    TblModuleManifestJpaController tblModuleManifestJpaController = getModuleJpaController();
    try {
        TblMle tblMle = tblMleJpaController.findVmmMle(host.VMM_Name, host.VMM_Version, host.VMM_OSName, host.VMM_OSVersion);
        if (tblMle != null) {
            // Retrieve the list of all the modules for the specified VMM MLE.
            List<TblModuleManifest> moduleList = tblModuleManifestJpaController.findTblModuleManifestByHardwareUuid(host.Hardware_Uuid);
            if (moduleList != null && moduleList.size() > 0) {
                for (TblModuleManifest moduleObj : moduleList) {
                    //if (moduleObj.getUseHostSpecificDigestValue()) // we cannot delete the host specific one since it would be referenced by the Hosts
                    //    continue;
                    tblModuleManifestJpaController.destroy(moduleObj.getId());
                }
            }
        }
    } catch (IllegalOrphanException | NonexistentEntityException ex) {
        log.error("Error during the deletion of VMM modules {}. ", host.VMM_Name, ex);
        throw new ASException(ErrorCode.WS_MODULE_WHITELIST_DELETE_ERROR, ex.getClass().getSimpleName());
    }
}
Also used : IllegalOrphanException(com.intel.mtwilson.as.controller.exceptions.IllegalOrphanException) TblMleJpaController(com.intel.mtwilson.as.controller.TblMleJpaController) TblModuleManifestJpaController(com.intel.mtwilson.as.controller.TblModuleManifestJpaController) TblMle(com.intel.mtwilson.as.data.TblMle) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) TblModuleManifest(com.intel.mtwilson.as.data.TblModuleManifest) ASException(com.intel.mountwilson.as.common.ASException)

Example 39 with NonexistentEntityException

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

the class HostBO method deleteSAMLAssertions.

/**
         * Deletes all the SAML assertions for the specified host. This should
         * be called before deleting the host.
         *
         * @param hostId
         */
private void deleteSAMLAssertions(TblHosts hostId) throws IOException {
    TblSamlAssertionJpaController samlJpaController = getSamlAssertionJpaController();
    List<TblSamlAssertion> hostSAMLAssertions = samlJpaController.findByHostID(hostId);
    if (hostSAMLAssertions != null) {
        for (TblSamlAssertion hostSAML : hostSAMLAssertions) {
            try {
                samlJpaController.destroy(hostSAML.getId());
            } catch (NonexistentEntityException e) {
                log.error("Ta Log is already deleted " + hostSAML.getId());
            }
        }
        log.info("Deleted all the logs for the given host " + hostId);
    }
}
Also used : TblSamlAssertionJpaController(com.intel.mtwilson.as.controller.TblSamlAssertionJpaController) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) TblSamlAssertion(com.intel.mtwilson.as.data.TblSamlAssertion)

Example 40 with NonexistentEntityException

use of com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException 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);
    }
}
Also used : TblTaLogJpaController(com.intel.mtwilson.as.controller.TblTaLogJpaController) TblTaLog(com.intel.mtwilson.as.data.TblTaLog) NonexistentEntityException(com.intel.mtwilson.as.controller.exceptions.NonexistentEntityException) Date(java.util.Date)

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