logo
down
shadow

RestTemplate mapping Page 'Page size must not be less than one'


RestTemplate mapping Page 'Page size must not be less than one'

By : doingit
Date : October 16 2020, 06:10 PM
I think the issue was by ths following , Solution: The below is a sample code that works fine in my spring boot project.
Step(1): Create a custom class that extends the PageImpl<>. because the PageImpl<> does not have empty constructor and therefore can not be used in deserialization. Also note that the below annotations will be used by jackson.
code :
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import java.util.ArrayList;
import java.util.List;

public class JacksonPageImpl<T> extends PageImpl<T> {

    private static final long serialVersionUID = 1230183330548294567L;

    @JsonCreator(mode = JsonCreator.Mode.PROPERTIES)
    public JacksonPageImpl(@JsonProperty("content") List<T> content,
                           @JsonProperty("number") int number,
                           @JsonProperty("size") int size,
                           @JsonProperty("totalElements") Long totalElements,
                           @JsonProperty("pageable") JsonNode pageable,
                           @JsonProperty("last") boolean last,
                           @JsonProperty("totalPages") int totalPages,
                           @JsonProperty("sort") JsonNode sort,
                           @JsonProperty("first") boolean first,
                           @JsonProperty("numberOfElements") int numberOfElements) {
        super(content, PageRequest.of(number, size), totalElements);
    }

    public JacksonPageImpl(List<T> content, Pageable pageable, long total) {
        super(content, pageable, total);
    }

    public JacksonPageImpl(List<T> content) {
        super(content);
    }

    public JacksonPageImpl() {
        super(new ArrayList<>());
    }

}

private String getPages(int pageNumber, int pageSize, ...){
    String url = "https://example.com/your_endpoint?page=" + pageNumber + "&size="+pageSize;
    //for example here: your_endpoint = endpoint1/endpoint2

    HttpHeaders headers = new HttpHeaders();
    headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
    //if you have authorization (basic,oauth,...) in server side:
    //headers.add("Authorization", ...);

    HttpEntity<String> request = new HttpEntity<>(headers);

    RestTemplate restTemplate = new RestTemplate();   
    ParameterizedTypeReference<WrapperRestResponse<T>> typeRef = new ParameterizedTypeReference<WrapperRestResponse<T>>(){};

    ResponseEntity<WrapperRestResponse> rsp = restTemplate.exchange(url, HttpMethod.GET, request, typeRef);
    if(rsp.getStatusCodeValue() == 200){
        WrapperRestResponse<T> pojoAnswer = rsp.getBody();
        JacksonPageImpl<T> page = pojoAnswer.getPage();
        List<T> contents = page.getContent();
        //continue your logic...
    }
    //...
}

public class WrapperRestResponse<T> {

    private JacksonPageImpl<T> page;
    //you can have other fields too

    public WrapperRestResponse() {
    }
    public WrapperRestResponse(JacksonPageImpl<T> page, ...) {
         this.page = page;
         //other fields...
    }

    public JacksonPageImpl<T> getPage() {
        return page;
    }

    //other fileds getter & setters

}
@RestController
@RequestMapping(value = "/endpoint1", produces = "application/json")
public class ResourceController {

    //...

    @GetMapping("/endpoint2")
    public ResponseEntity getPages(Pageable pageable, ...){
        Page<T> pages = ...;//get it by your logic
        //...
        return ResponseEntity.ok(new WrapperRestResponse(pages, ...));
    }
}


Share : facebook icon twitter icon
How can the Page Size, Page Orientation, and Page Margins of an ods Spreadsheet Be Set Using ODFDOM?

How can the Page Size, Page Orientation, and Page Margins of an ods Spreadsheet Be Set Using ODFDOM?


By : Tom Haug
Date : March 29 2020, 07:55 AM
I wish this helpful for you The necessary calls can be made to some of the underlying ODF objects which the SpreadsheetDocument provides access to. First, we need to get the proper document properties reference (for all examples, "spreadsheet" is a reference to a created SpreadsheetDocument):
code :
    StyleMasterPageElement defaultPage = spreadsheet.getOfficeMasterStyles().getMasterPage("Default");
    String pageLayoutName = defaultPage.getStylePageLayoutNameAttribute();
    OdfStylePageLayout pageLayoutStyle = defaultPage.getAutomaticStyles().getPageLayout(pageLayoutName);
    PageLayoutProperties pageLayoutProps = PageLayoutProperties.getOrCreatePageLayoutProperties(pageLayoutStyle);
    pageLayoutProperties.setPageHeight(pageHeightInMM);
    pageLayoutProperties.setPageWidth(pageWidthInMM);
    pageLayoutProperties.setPrintOrientation(PrintOrientation.LANDSCAPE);
    pageLayoutProperties.setMarginLeft(leftMarginInMM);
    pageLayoutProperties.setMarginRight(rightMarginInMM);
    pageLayoutProperties.setMarginTop(topMarginInMM);
    pageLayoutProperties.setMarginBottom(bottomMarginInMM);
How to find the largest page size that could be used for a specific virtual to physical address mapping?

How to find the largest page size that could be used for a specific virtual to physical address mapping?


By : itmaktub
Date : March 29 2020, 07:55 AM
wish help you to fix your issue The low order bits make up the page offset which is always the same between a virtual address and it's mapping to a physical address. Therefore, we need to find the low order bits of the hex values given.
0x52D2C3A3 = 0000 0000 0101 0010 1101 0010 1100 0011 1010 0011
DoubleClick for Publishers Out-Of-Page Slot with Size Mapping for Responsive sites

DoubleClick for Publishers Out-Of-Page Slot with Size Mapping for Responsive sites


By : Rumpelstiltskin
Date : March 29 2020, 07:55 AM
this will help Well, after I refined my google search to include "out-of-page", in quotes, I was able to find a Google Group for DFP with the answer!
https://productforums.google.com/forum/#!topic/dfp/OqW_uLU9TJ0
code :
 var sizeMapping = googletag.sizeMapping().
       addSize([0, 0], []).
       addSize([1210, 0], [1, 1]).
       build();


 googletag.defineOutOfPageSlot('...','...').defineSizeMapping(sizeMapping).addService(googletag.pubads());
Relationship between page table size and page size in operating system

Relationship between page table size and page size in operating system


By : ivan krivzov
Date : March 29 2020, 07:55 AM
Any of those help the basic requirement for multilevel paging is pagetable size less than equal to frame size, and since frame size equals page size, so page table size less than equal to page size.
How does postgres stores row in page, when row size exceeds available free size in page ?

How does postgres stores row in page, when row size exceeds available free size in page ?


By : Muhammed Sefa KOÇAKO
Date : March 29 2020, 07:55 AM
will help you First, I should clarify that “enough room in the table page” has nothing to do with the question if an attribute is TOASTed or not.
The paragraph you quote describes how TOAST tries to reduce the size of a table row that exceeds 2KB by first compressing the values and then storing them “out of line” in a TOAST table.
Related Posts Related Posts :
  • How to use Java generics method?
  • How would I fix the Syntax error insert '}' to complete block
  • 2-D Arrays in Java
  • Java OOP exercise
  • Accessing DLL pointers through Java
  • Runnable::new vs new Runnable()
  • Java Get last key from Hashmap
  • Struts2 - The list key couldn't be resolved
  • h2 (embedded mode ) database files problem
  • Is there a timeout for threads waiting on a synchronised method in Java?
  • WTK emulator bluetooth connection
  • Cannot find a free socket for the debugger in eclipse
  • Hibernate - EhCache - Which region to Cache associations/sets/collections?
  • Struts 1 - struts-taglib.jar is not being found by my web application
  • return type of main in java
  • how to create internal frame in netbeans platform?
  • java: Read text file and store the info in an array using scanner class
  • Dynamically building and updating Histograms with JFreeChart
  • the characters except 0x00-0x7F are not been shown when converted to "UTF-8" from "ISO-8859-1"
  • scala 2.8 implict java collections conversions
  • Pure Java HTML viewer/renderer for use in a Scrollable pane
  • Analysing a JVisualVM profile - finding the source of large numbers of primitive types?
  • Java multi-threading - what is the best way to monitor the activity of a number of threads?
  • Why output keeps same many output?
  • Isn’t there an “132” pattern in [3,5,0,3,4]?
  • Android playing Video data from a custom network stream?
  • generation of random numbers in java
  • Anyone know about Jasypt (Java encryption library)?
  • Use class name as root key for JSON Jackson serialization
  • Java - Removing duplicates in an ArrayList
  • How do I alias the scala setter method 'myvar_$eq(myval)' to something more pleasing when in java?
  • Difference in System. exit(0) , System.exit(-1), System.exit(1 ) in Java
  • Read multiple lines from InputStreamReader (JAVA)
  • How to open new applet window from a applet
  • Getting Google results in Java? Need help!
  • Smart Cards Development
  • Is there a possibility to run applets on Android or Blackberry?
  • what does a tool like Jasper Reports/report generator gives me?
  • How to create docking panel in Java?
  • Where and why JVM checks that the return type of entry method main(String args[]) is void and not anything else?
  • Static value in for loop
  • Difference between Class c; and Class c=new Class();
  • My question is about Regular Expression in java
  • Why can't I write ch=ch+1; instead of ch++; though they have same meaning
  • Why is this loop changed?
  • Java (Read and write to file)
  • What's ideal debugging setup? window placement etc
  • Java app behind proxy to use http_proxy variable in linux
  • Straight Java/Groovy versus ETL tool (Talend/etc) - what libraries would you use?
  • Performance testing Flex applications
  • How to insert into two different tables in one statement with Java and MySQL?
  • Object Serialization for Undo/Redo Functionality Java
  • How to retrieve the last image from an SDcard in Android?
  • What's the fastest way to draw a Hello World in Java
  • Java error on bilinear interpolation of 16 bit data
  • Java equivalent for database schema changes like South for Django?
  • Java Robot key activity seems to stop working while certain software is running
  • Will using multiple version of a jar in an application cause problems?
  • JSF RuntimeException: Cannot find FacesContext
  • How do i get a particular day from Jan to Dec
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk