From ddada80add97ce50e12066fe344f7b3c47542667 Mon Sep 17 00:00:00 2001 From: chubtub <43381989+chubtub@users.noreply.github.com> Date: Fri, 15 Oct 2021 10:53:41 -0400 Subject: [PATCH] WIP: frontend hangs while getting records from backend --- .../controllers/TpmEventsPageController.java | 20 ++++++++++++++++--- .../java/hirs/persist/AbstractDbManager.java | 17 +++++++++++++++- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/TpmEventsPageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/TpmEventsPageController.java index d5f1f174..10d447e9 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/TpmEventsPageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/TpmEventsPageController.java @@ -10,12 +10,16 @@ import hirs.attestationca.portal.page.PageController; import hirs.attestationca.portal.page.params.NoPageParams; import hirs.data.persist.ReferenceDigestRecord; import hirs.data.persist.ReferenceDigestValue; +import hirs.data.persist.certificate.Certificate; +import hirs.persist.CriteriaModifier; import hirs.persist.DBReferenceDigestManager; import hirs.persist.DBReferenceEventManager; import hirs.persist.ReferenceDigestManager; import hirs.persist.ReferenceEventManager; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.hibernate.Criteria; +import org.hibernate.criterion.Restrictions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; @@ -135,17 +139,27 @@ public class TpmEventsPageController method = RequestMethod.GET) public DataTableResponse getTableData( final DataTableInput input) { - LOGGER.debug("Handling request for summary list: " + input); + LOGGER.info("Handling request for summary list: " + input); String orderColumnName = input.getOrderColumnName(); - LOGGER.debug("Ordering on column: " + orderColumnName); + LOGGER.info("Ordering on column: " + orderColumnName); + + // check that the alert is not archived and that it is in the specified report + CriteriaModifier criteriaModifier = new CriteriaModifier() { + @Override + public void modify(final Criteria criteria) { + criteria.add(Restrictions.isNull(Certificate.ARCHIVE_FIELD)); + } + }; LOGGER.info("Querying with the following datatableinput: " + input.toString()); FilteredRecordsList referenceDigestRecords = OrderedListQueryDataTableAdapter.getOrderedList( ReferenceDigestRecord.class, referenceDigestManager, - input, orderColumnName); + input, orderColumnName, criteriaModifier); + LOGGER.info("ReferenceDigestManager returned: " + + Arrays.toString(referenceDigestRecords.toArray())); FilteredRecordsList> mappedRecordValues = mapRecordToValues(referenceDigestRecords); diff --git a/HIRS_Utils/src/main/java/hirs/persist/AbstractDbManager.java b/HIRS_Utils/src/main/java/hirs/persist/AbstractDbManager.java index f2250720..73b0e308 100644 --- a/HIRS_Utils/src/main/java/hirs/persist/AbstractDbManager.java +++ b/HIRS_Utils/src/main/java/hirs/persist/AbstractDbManager.java @@ -35,6 +35,7 @@ import java.io.Serializable; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.HashSet; import java.util.List; @@ -766,6 +767,10 @@ public abstract class AbstractDbManager implements CrudManager { searchClass = this.clazz; } + LOGGER.info(clazz.getName() + " querying for " + + Arrays.toString(searchableColumns.entrySet().toArray()) + + " with search strings \"" + search + "\""); + //Object that will store query values FilteredRecordsList aqr = new FilteredRecordsList<>(); @@ -786,6 +791,7 @@ public abstract class AbstractDbManager implements CrudManager { Long recordsFiltered = totalResultCount; Conjunction and = Restrictions.conjunction(); if (totalResultCount != 0) { + LOGGER.info("Total result count greater than 0"); //Builds the search criteria from all of the searchable columns if (searchableColumns != null) { // Search for all words in all searchable columns @@ -804,10 +810,18 @@ public abstract class AbstractDbManager implements CrudManager { } } + LOGGER.info("Search columns filtered"); //Retrieves a count of all the records after being filtered criteria.setProjection(Projections.countDistinct("id")) .add(and); - recordsFiltered = (Long) criteria.uniqueResult(); + try { + LOGGER.info("Get unique result from criteria object"); + recordsFiltered = (Long) criteria.uniqueResult(); + } catch (HibernateException e) { + LOGGER.info(e.getMessage()); + } catch (Exception e) { + LOGGER.info("Error while getting unique result: " + e.getMessage()); + } } if (recordsFiltered != 0) { @@ -867,6 +881,7 @@ public abstract class AbstractDbManager implements CrudManager { } throw e; } + LOGGER.info(clazz.getName() + " found " + aqr.getRecordsTotal() + " records"); return aqr; }