WIP: frontend hangs while getting records from backend

This commit is contained in:
chubtub 2021-10-15 10:53:41 -04:00
parent 7d8df398e7
commit ddada80add
2 changed files with 33 additions and 4 deletions

View File

@ -10,12 +10,16 @@ import hirs.attestationca.portal.page.PageController;
import hirs.attestationca.portal.page.params.NoPageParams; import hirs.attestationca.portal.page.params.NoPageParams;
import hirs.data.persist.ReferenceDigestRecord; import hirs.data.persist.ReferenceDigestRecord;
import hirs.data.persist.ReferenceDigestValue; import hirs.data.persist.ReferenceDigestValue;
import hirs.data.persist.certificate.Certificate;
import hirs.persist.CriteriaModifier;
import hirs.persist.DBReferenceDigestManager; import hirs.persist.DBReferenceDigestManager;
import hirs.persist.DBReferenceEventManager; import hirs.persist.DBReferenceEventManager;
import hirs.persist.ReferenceDigestManager; import hirs.persist.ReferenceDigestManager;
import hirs.persist.ReferenceEventManager; import hirs.persist.ReferenceEventManager;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; 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.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -135,17 +139,27 @@ public class TpmEventsPageController
method = RequestMethod.GET) method = RequestMethod.GET)
public DataTableResponse<ReferenceDigestRecord> getTableData( public DataTableResponse<ReferenceDigestRecord> getTableData(
final DataTableInput input) { final DataTableInput input) {
LOGGER.debug("Handling request for summary list: " + input); LOGGER.info("Handling request for summary list: " + input);
String orderColumnName = input.getOrderColumnName(); 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()); LOGGER.info("Querying with the following datatableinput: " + input.toString());
FilteredRecordsList<ReferenceDigestRecord> referenceDigestRecords FilteredRecordsList<ReferenceDigestRecord> referenceDigestRecords
= OrderedListQueryDataTableAdapter.getOrderedList( = OrderedListQueryDataTableAdapter.getOrderedList(
ReferenceDigestRecord.class, ReferenceDigestRecord.class,
referenceDigestManager, referenceDigestManager,
input, orderColumnName); input, orderColumnName, criteriaModifier);
LOGGER.info("ReferenceDigestManager returned: "
+ Arrays.toString(referenceDigestRecords.toArray()));
FilteredRecordsList<HashMap<ReferenceDigestRecord, ReferenceDigestValue>> FilteredRecordsList<HashMap<ReferenceDigestRecord, ReferenceDigestValue>>
mappedRecordValues = mapRecordToValues(referenceDigestRecords); mappedRecordValues = mapRecordToValues(referenceDigestRecords);

View File

@ -35,6 +35,7 @@ import java.io.Serializable;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
@ -766,6 +767,10 @@ public abstract class AbstractDbManager<T> implements CrudManager<T> {
searchClass = this.clazz; searchClass = this.clazz;
} }
LOGGER.info(clazz.getName() + " querying for "
+ Arrays.toString(searchableColumns.entrySet().toArray())
+ " with search strings \"" + search + "\"");
//Object that will store query values //Object that will store query values
FilteredRecordsList<T> aqr = new FilteredRecordsList<>(); FilteredRecordsList<T> aqr = new FilteredRecordsList<>();
@ -786,6 +791,7 @@ public abstract class AbstractDbManager<T> implements CrudManager<T> {
Long recordsFiltered = totalResultCount; Long recordsFiltered = totalResultCount;
Conjunction and = Restrictions.conjunction(); Conjunction and = Restrictions.conjunction();
if (totalResultCount != 0) { if (totalResultCount != 0) {
LOGGER.info("Total result count greater than 0");
//Builds the search criteria from all of the searchable columns //Builds the search criteria from all of the searchable columns
if (searchableColumns != null) { if (searchableColumns != null) {
// Search for all words in all searchable columns // Search for all words in all searchable columns
@ -804,10 +810,18 @@ public abstract class AbstractDbManager<T> implements CrudManager<T> {
} }
} }
LOGGER.info("Search columns filtered");
//Retrieves a count of all the records after being filtered //Retrieves a count of all the records after being filtered
criteria.setProjection(Projections.countDistinct("id")) criteria.setProjection(Projections.countDistinct("id"))
.add(and); .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) { if (recordsFiltered != 0) {
@ -867,6 +881,7 @@ public abstract class AbstractDbManager<T> implements CrudManager<T> {
} }
throw e; throw e;
} }
LOGGER.info(clazz.getName() + " found " + aqr.getRecordsTotal() + " records");
return aqr; return aqr;
} }