ProductType type = client.getProductTypeByName(productTypeName);
if (type == null) {
throw new Exception("FileManager returned null ProductType");
}
ProductPage firstPage = client.getFirstPage(type);
if (firstPage == null) {
throw new Exception("FileManager returned null first ProductPage");
}
ProductPage currentPage = new ProductPage();
currentPage.setPageNum(currentPageNum);
currentPage.setPageSize(firstPage.getPageSize());
currentPage.setTotalPages(firstPage.getTotalPages());
ProductPage prevPage = client.getPrevPage(type, currentPage);
if (prevPage == null) {
throw new Exception("FileManager returned null previous ProductPage");
}
printer.println("Page: [num=" + prevPage.getPageNum()
+ ", totalPages=" + prevPage.getTotalPages() + ", pageSize="
+ prevPage.getPageSize() + "]");
printer.println("Products:");
if (prevPage.getPageProducts() == null) {
throw new NullPointerException(
"FileManager returned null page Products");
}
for (Product p : prevPage.getPageProducts()) {
printer.println("Product: [id=" + p.getProductId() + ",name="
+ p.getProductName() + ",type="
+ p.getProductType().getName() + ",structure="
+ p.getProductStructure() + ", transferStatus="
+ p.getTransferStatus() + "]");