mirror of
https://github.com/nsacyber/HIRS.git
synced 2024-12-20 21:43:18 +00:00
Merge pull request #569 from nsacyber/v3_list-page-fix
[#534] List Elements page fix
This commit is contained in:
commit
afee8019af
@ -17,7 +17,6 @@ public interface ReferenceDigestValueRepository extends JpaRepository<ReferenceD
|
||||
List<ReferenceDigestValue> findByManufacturer(String manufacturer);
|
||||
@Query(value = "SELECT * FROM ReferenceDigestValue WHERE baseRimId = '?1' OR supportRimId = '?1'", nativeQuery = true)
|
||||
List<ReferenceDigestValue> getValuesByRimId(UUID associatedRimId);
|
||||
@Query(value = "SELECT * FROM ReferenceDigestValue WHERE supportRimId = '?1'", nativeQuery = true)
|
||||
List<ReferenceDigestValue> findBySupportRimId(UUID supportRimId);
|
||||
List<ReferenceDigestValue> findBySupportRimHash(String supportRimHash);
|
||||
}
|
||||
|
@ -28,6 +28,10 @@ public abstract class DeviceAssociatedCertificate extends Certificate {
|
||||
@JdbcTypeCode(java.sql.Types.VARCHAR)
|
||||
@Column
|
||||
private UUID deviceId;
|
||||
@Getter
|
||||
@Setter
|
||||
@Column
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* Holds the name of the entity 'DEVICE_ID' field.
|
||||
|
@ -31,6 +31,9 @@ import lombok.extern.log4j.Log4j2;
|
||||
import org.bouncycastle.util.encoders.DecoderException;
|
||||
import org.hibernate.Session;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@ -58,9 +61,6 @@ import java.util.UUID;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
//import java.security.cert.CertificateEncodingException;
|
||||
//import java.security.cert.X509Certificate;
|
||||
|
||||
// note uploading base64 certs, old or new having decode issues check ACA channel
|
||||
|
||||
/**
|
||||
@ -220,19 +220,24 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
||||
}
|
||||
};
|
||||
|
||||
int currentPage = input.getStart() / input.getLength();
|
||||
Pageable paging = PageRequest.of(currentPage, input.getLength(), Sort.by(orderColumnName));
|
||||
|
||||
/**
|
||||
* Ok I think what I will do is make repositories for each certificate type to I can
|
||||
* tell it what the type T is.
|
||||
*/
|
||||
FilteredRecordsList<Certificate> records = new FilteredRecordsList<>();
|
||||
// special parsing for platform credential
|
||||
// Add the EndorsementCredential for each PlatformCredential based on the
|
||||
// serial number. (pc.HolderSerialNumber = ec.SerialNumber)
|
||||
if (certificateType.equals(PLATFORMCREDENTIAL)) {
|
||||
records = OrderedListQueryDataTableAdapter.getOrderedList(
|
||||
getCertificateClass(certificateType), platformCertificateRepository,
|
||||
input, orderColumnName, criteriaModifier);
|
||||
// records = OrderedListQueryDataTableAdapter.getOrderedList(
|
||||
// getCertificateClass(certificateType), platformCertificateRepository,
|
||||
// input, orderColumnName, criteriaModifier);
|
||||
FilteredRecordsList<PlatformCredential> records = new FilteredRecordsList<>();
|
||||
|
||||
org.springframework.data.domain.Page<PlatformCredential> pagedResult = this.platformCertificateRepository.findAll(paging);
|
||||
if (pagedResult.hasContent()) {
|
||||
records.addAll(pagedResult.getContent());
|
||||
}
|
||||
records.setRecordsTotal(input.getLength());
|
||||
records.setRecordsFiltered(platformCertificateRepository.count());
|
||||
EndorsementCredential associatedEC;
|
||||
|
||||
if (!records.isEmpty()) {
|
||||
@ -251,18 +256,53 @@ public class CertificatePageController extends PageController<NoPageParams> {
|
||||
pc.setEndorsementCredential(associatedEC);
|
||||
}
|
||||
}
|
||||
|
||||
log.debug("Returning list of size: " + records.size());
|
||||
return new DataTableResponse<>(records, input);
|
||||
} else if (certificateType.equals(ENDORSEMENTCREDENTIAL)) {
|
||||
records = OrderedListQueryDataTableAdapter.getOrderedList(
|
||||
getCertificateClass(certificateType), endorsementCredentialRepository,
|
||||
input, orderColumnName, criteriaModifier);
|
||||
// records = OrderedListQueryDataTableAdapter.getOrderedList(
|
||||
// getCertificateClass(certificateType), endorsementCredentialRepository,
|
||||
// input, orderColumnName, criteriaModifier);
|
||||
FilteredRecordsList<EndorsementCredential> records = new FilteredRecordsList<>();
|
||||
org.springframework.data.domain.Page<EndorsementCredential> pagedResult = this.endorsementCredentialRepository.findAll(paging);
|
||||
if (pagedResult.hasContent()) {
|
||||
records.addAll(pagedResult.getContent());
|
||||
}
|
||||
|
||||
records.setRecordsTotal(input.getLength());
|
||||
records.setRecordsFiltered(endorsementCredentialRepository.count());
|
||||
|
||||
log.debug("Returning list of size: " + records.size());
|
||||
return new DataTableResponse<>(records, input);
|
||||
} else if (certificateType.equals(TRUSTCHAIN)) {
|
||||
records = OrderedListQueryDataTableAdapter.getOrderedList(
|
||||
getCertificateClass(certificateType), caCredentialRepository,
|
||||
input, orderColumnName, criteriaModifier);
|
||||
// records = OrderedListQueryDataTableAdapter.getOrderedList(
|
||||
// getCertificateClass(certificateType), caCredentialRepository,
|
||||
// input, orderColumnName, criteriaModifier);
|
||||
FilteredRecordsList<CertificateAuthorityCredential> records = new FilteredRecordsList<>();
|
||||
org.springframework.data.domain.Page<CertificateAuthorityCredential> pagedResult = this.caCredentialRepository.findAll(paging);
|
||||
|
||||
if (pagedResult.hasContent()) {
|
||||
records.addAll(pagedResult.getContent());
|
||||
}
|
||||
records.setRecordsTotal(input.getLength());
|
||||
records.setRecordsFiltered(caCredentialRepository.count());
|
||||
|
||||
log.debug("Returning list of size: " + records.size());
|
||||
return new DataTableResponse<>(records, input);
|
||||
} else if (certificateType.equals(ISSUEDCERTIFICATES)) {
|
||||
FilteredRecordsList<IssuedAttestationCertificate> records = new FilteredRecordsList<>();
|
||||
org.springframework.data.domain.Page<IssuedAttestationCertificate> pagedResult = this.issuedCertificateRepository.findAll(paging);
|
||||
if (pagedResult.hasContent()) {
|
||||
records.addAll(pagedResult.getContent());
|
||||
}
|
||||
records.setRecordsTotal(input.getLength());
|
||||
records.setRecordsFiltered(issuedCertificateRepository.count());
|
||||
|
||||
log.debug("Returning list of size: " + records.size());
|
||||
return new DataTableResponse<>(records, input);
|
||||
}
|
||||
|
||||
log.debug("Returning list of size: " + records.size());
|
||||
return new DataTableResponse<>(records, input);
|
||||
return new DataTableResponse<Certificate>(new FilteredRecordsList<>(), input);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -20,6 +20,9 @@ import hirs.attestationca.portal.page.PageController;
|
||||
import hirs.attestationca.portal.page.params.NoPageParams;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@ -80,16 +83,26 @@ public class DevicePageController extends PageController<NoPageParams> {
|
||||
log.info("Ordering on column: " + orderColumnName);
|
||||
|
||||
// get all the devices
|
||||
FilteredRecordsList<Device> deviceList =
|
||||
OrderedListQueryDataTableAdapter.getOrderedList(
|
||||
Device.class,
|
||||
deviceRepository,
|
||||
input, orderColumnName);
|
||||
FilteredRecordsList<Device> deviceList = new FilteredRecordsList<>();
|
||||
// OrderedListQueryDataTableAdapter.getOrderedList(
|
||||
// Device.class,
|
||||
// deviceRepository,
|
||||
// input, orderColumnName);
|
||||
|
||||
FilteredRecordsList<HashMap<String, Object>> record
|
||||
int currentPage = input.getStart() / input.getLength();
|
||||
Pageable paging = PageRequest.of(currentPage, input.getLength(), Sort.by(orderColumnName));
|
||||
org.springframework.data.domain.Page<Device> pagedResult = deviceRepository.findAll(paging);
|
||||
|
||||
if (pagedResult.hasContent()) {
|
||||
deviceList.addAll(pagedResult.getContent());
|
||||
}
|
||||
deviceList.setRecordsTotal(input.getLength());
|
||||
deviceList.setRecordsFiltered(deviceRepository.count());
|
||||
|
||||
FilteredRecordsList<HashMap<String, Object>> records
|
||||
= retrieveDevicesAndAssociatedCertificates(deviceList);
|
||||
|
||||
return new DataTableResponse<>(record, input);
|
||||
return new DataTableResponse<>(records, input);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -312,7 +312,7 @@ public class ReferenceManifestDetailsPageController extends PageController<Refer
|
||||
}
|
||||
}
|
||||
} catch (NullPointerException e) {
|
||||
log.error("Unable to link signing certificate: " + e.getMessage());
|
||||
log.warn("Unable to link signing certificate: " + e.getMessage());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
@ -28,6 +28,9 @@ import jakarta.validation.Valid;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.hibernate.Session;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@ -132,11 +135,24 @@ public class ReferenceManifestPageController extends PageController<NoPageParams
|
||||
criteriaQuery.select(rimRoot).distinct(true).where(cb.isNull(rimRoot.get(Certificate.ARCHIVE_FIELD)));
|
||||
}
|
||||
};
|
||||
FilteredRecordsList<ReferenceManifest> records
|
||||
= OrderedListQueryDataTableAdapter.getOrderedList(
|
||||
ReferenceManifest.class,
|
||||
this.referenceManifestRepository,
|
||||
input, orderColumnName, criteriaModifier);
|
||||
|
||||
log.info("Querying with the following dataTableInput: " + input.toString());
|
||||
|
||||
FilteredRecordsList<ReferenceManifest> records = new FilteredRecordsList<>();
|
||||
int currentPage = input.getStart() / input.getLength();
|
||||
Pageable paging = PageRequest.of(currentPage, input.getLength(), Sort.by(orderColumnName));
|
||||
org.springframework.data.domain.Page<ReferenceManifest> pagedResult = referenceManifestRepository.findAll(paging);
|
||||
|
||||
if (pagedResult.hasContent()) {
|
||||
records.addAll(pagedResult.getContent());
|
||||
}
|
||||
records.setRecordsTotal(input.getLength());
|
||||
records.setRecordsFiltered(referenceManifestRepository.count());
|
||||
// FilteredRecordsList<ReferenceManifest> records
|
||||
// = OrderedListQueryDataTableAdapter.getOrderedList(
|
||||
// ReferenceManifest.class,
|
||||
// this.referenceManifestRepository,
|
||||
// input, orderColumnName, criteriaModifier);
|
||||
|
||||
log.debug("Returning list of size: " + records.size());
|
||||
return new DataTableResponse<>(records, input);
|
||||
|
@ -106,17 +106,19 @@ public class RimDatabasePageController extends PageController<NoPageParams> {
|
||||
}
|
||||
};
|
||||
|
||||
log.info("Querying with the following datatableinput: " + input.toString());
|
||||
FilteredRecordsList<ReferenceDigestValue> referenceDigestValues = new FilteredRecordsList<>();
|
||||
Pageable paging = PageRequest.of(input.getStart(), input.getLength(), Sort.by(orderColumnName));
|
||||
log.info("Querying with the following dataTableInput: " + input.toString());
|
||||
|
||||
FilteredRecordsList<ReferenceDigestValue> referenceDigestValues = new FilteredRecordsList<>();
|
||||
|
||||
int currentPage = input.getStart() / input.getLength();
|
||||
Pageable paging = PageRequest.of(currentPage, input.getLength(), Sort.by(orderColumnName));
|
||||
org.springframework.data.domain.Page<ReferenceDigestValue> pagedResult = referenceDigestValueRepository.findAll(paging);
|
||||
|
||||
if (pagedResult.hasContent()) {
|
||||
referenceDigestValues.addAll(pagedResult.getContent());
|
||||
}
|
||||
referenceDigestValues.setRecordsTotal(referenceDigestValueRepository.count());
|
||||
referenceDigestValues.setRecordsFiltered(input.getLength());
|
||||
referenceDigestValues.setRecordsTotal(input.getLength());
|
||||
referenceDigestValues.setRecordsFiltered(referenceDigestValueRepository.count());
|
||||
|
||||
// FilteredRecordsList<ReferenceDigestValue> referenceDigestValues =
|
||||
// OrderedListQueryDataTableAdapter.getOrderedList(
|
||||
@ -140,6 +142,7 @@ public class RimDatabasePageController extends PageController<NoPageParams> {
|
||||
}
|
||||
}
|
||||
|
||||
log.debug("Returning list of size: " + referenceDigestValues.size());
|
||||
return new DataTableResponse<>(referenceDigestValues, input);
|
||||
}
|
||||
}
|
||||
|
@ -29,6 +29,9 @@ import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.hibernate.Session;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
@ -121,23 +124,13 @@ public class ValidationReportsPageController extends PageController<NoPageParams
|
||||
final DataTableInput input) {
|
||||
|
||||
log.debug("Handling request for summary list: " + input);
|
||||
|
||||
// attempt to get the column property based on the order index.
|
||||
String orderColumnName = input.getOrderColumnName();
|
||||
|
||||
log.debug("Ordering on column: " + orderColumnName);
|
||||
|
||||
// define an alias so the composite object, device, can be used by the
|
||||
// datatables / query. This is necessary so the device.name property can
|
||||
// be used.
|
||||
// CriteriaModifier criteriaModifier = new CriteriaModifier() {
|
||||
// @Override
|
||||
// public void modify(final Criteria criteria) {
|
||||
// criteria.add(RowMutationOperations.Restrictions.isNull(Certificate.ARCHIVE_FIELD));
|
||||
// criteria.createAlias("device", "device");
|
||||
// }
|
||||
// };
|
||||
|
||||
CriteriaModifier criteriaModifier = new CriteriaModifier() {
|
||||
@Override
|
||||
public void modify(final CriteriaQuery criteriaQuery) {
|
||||
@ -149,11 +142,22 @@ public class ValidationReportsPageController extends PageController<NoPageParams
|
||||
}
|
||||
};
|
||||
|
||||
FilteredRecordsList<SupplyChainValidationSummary> records =
|
||||
OrderedListQueryDataTableAdapter.getOrderedList(
|
||||
SupplyChainValidationSummary.class,
|
||||
supplyChainValidatorSummaryRepository, input, orderColumnName,
|
||||
criteriaModifier);
|
||||
FilteredRecordsList<SupplyChainValidationSummary> records = new FilteredRecordsList<>();
|
||||
int currentPage = input.getStart() / input.getLength();
|
||||
Pageable paging = PageRequest.of(currentPage, input.getLength(), Sort.by(orderColumnName));
|
||||
org.springframework.data.domain.Page<SupplyChainValidationSummary> pagedResult = supplyChainValidatorSummaryRepository.findAll(paging);
|
||||
|
||||
if (pagedResult.hasContent()) {
|
||||
records.addAll(pagedResult.getContent());
|
||||
}
|
||||
records.setRecordsTotal(input.getLength());
|
||||
records.setRecordsFiltered(supplyChainValidatorSummaryRepository.count());
|
||||
|
||||
// FilteredRecordsList<SupplyChainValidationSummary> records =
|
||||
// OrderedListQueryDataTableAdapter.getOrderedList(
|
||||
// SupplyChainValidationSummary.class,
|
||||
// supplyChainValidatorSummaryRepository, input, orderColumnName,
|
||||
// criteriaModifier);
|
||||
|
||||
return new DataTableResponse<>(records, input);
|
||||
}
|
||||
|
@ -49,14 +49,14 @@
|
||||
var url = pagePath +'/list';
|
||||
var columns = [
|
||||
{
|
||||
data: 'device.name',
|
||||
data: 'deviceName',
|
||||
render: function (data, type, full, meta) {
|
||||
// if there's a device, display its name, otherwise
|
||||
// display nothing
|
||||
if (full.device) {
|
||||
// TODO render a link to a device details page,
|
||||
// passing the device.id
|
||||
return full.device.name;
|
||||
return full.deviceName;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
@ -44,14 +44,14 @@
|
||||
var url = pagePath + '/list';
|
||||
var columns = [
|
||||
{
|
||||
data: 'device.name',
|
||||
data: 'deviceName',
|
||||
render: function (data, type, full, meta) {
|
||||
// if there's a device, display its name, otherwise
|
||||
// display nothing
|
||||
if (full.device) {
|
||||
// TODO render a link to a device details page,
|
||||
// passing the device.id
|
||||
return full.device.name;
|
||||
return full.deviceName;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
@ -54,14 +54,14 @@
|
||||
var url = pagePath +'/list';
|
||||
var columns = [
|
||||
{
|
||||
data: 'device.name',
|
||||
data: 'deviceName',
|
||||
render: function (data, type, full, meta) {
|
||||
// if there's a device, display its name, otherwise
|
||||
// display nothing
|
||||
if (full.device) {
|
||||
// TODO render a link to a device details page,
|
||||
// passing the device.id
|
||||
return full.device.name;
|
||||
return full.deviceName;
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public final class BouncyCastleUtils {
|
||||
*/
|
||||
public static boolean x500NameCompare(final String nameValue1, final String nameValue2) {
|
||||
if (nameValue1 == null || nameValue2 == null) {
|
||||
log.error("Provided DN string is null.");
|
||||
log.warn("Provided DN string is null.");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user