diff --git a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/CertificatePageController.java b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/CertificatePageController.java index ceeb0da4..970c11b6 100644 --- a/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/CertificatePageController.java +++ b/HIRS_AttestationCAPortal/src/main/java/hirs/attestationca/portal/page/controllers/CertificatePageController.java @@ -215,9 +215,10 @@ public class CertificatePageController extends PageController { String orderColumnName = input.getOrderColumnName(); log.debug("Ordering on column: " + orderColumnName); - Order order = input.getOrder().get(0); - - + List orderList = input.getOrder(); + Order order = null; + if (orderList.size() > 0) + order = input.getOrder().get(0); int currentPage = input.getStart() / input.getLength(); Pageable paging = PageRequest.of(currentPage, input.getLength(), Sort.by(orderColumnName)); @@ -276,17 +277,19 @@ public class CertificatePageController extends PageController { } else if (certificateType.equals(TRUSTCHAIN)) { FilteredRecordsList records = new FilteredRecordsList<>(); org.springframework.data.domain.Page pagedResult = this.caCredentialRepository.findByArchiveFlag(false, paging);; - if (orderColumnName.equalsIgnoreCase("Issuer")) { - if (order.isAscending()) { - pagedResult = this.caCredentialRepository.findByArchiveFlagOrderByIssuerAsc(false, paging); - } else { - pagedResult = this.caCredentialRepository.findByArchiveFlagOrderByIssuerDesc(false, paging); - } - } else if (orderColumnName.equalsIgnoreCase("Subject")) { - if (order.isAscending()) { - pagedResult = this.caCredentialRepository.findByArchiveFlagOrderBySubjectAsc(false, paging); - } else { - pagedResult = this.caCredentialRepository.findByArchiveFlagOrderBySubjectDesc(false, paging); + if (order != null) { + if (orderColumnName.equalsIgnoreCase("Issuer")) { + if (order.isAscending()) { + pagedResult = this.caCredentialRepository.findByArchiveFlagOrderByIssuerAsc(false, paging); + } else { + pagedResult = this.caCredentialRepository.findByArchiveFlagOrderByIssuerDesc(false, paging); + } + } else if (orderColumnName.equalsIgnoreCase("Subject")) { + if (order.isAscending()) { + pagedResult = this.caCredentialRepository.findByArchiveFlagOrderBySubjectAsc(false, paging); + } else { + pagedResult = this.caCredentialRepository.findByArchiveFlagOrderBySubjectDesc(false, paging); + } } } @@ -626,8 +629,8 @@ public class CertificatePageController extends PageController { } private ZipOutputStream bulkDownload(final ZipOutputStream zipOut, - final List certificates, - final String singleFileName) throws IOException { + final List certificates, + final String singleFileName) throws IOException { String zipFileName; // get all files for (Certificate certificate : certificates) { @@ -1012,4 +1015,4 @@ public class CertificatePageController extends PageController { componentResultRepository.save(componentResult); } } -} +} \ No newline at end of file