Closed jollycar closed 5 years ago
Agree, this is a bug.
The API always returns a paginated list, if the client doesn't pass a Pageable (pageNo, pageSize, [sort])
a default pagination is applied (0, 20)
.
The Java api should include this default Pageable to the result page if the pagination input parameter is null.
Will fix in the next version !
Fixed in 0.1.16
When you try to search from the Java API (Page searchAndFetch(String indexName, Query query)), so without a Pagable, the (rest) server throws a 500 exception:
.m.m.a.ExceptionHandlerExceptionResolver : Resolved [java.lang.IllegalArgumentException: Pageable must not be null!]
My workaround is to create an arbitrary Pagable and use the other method in IPFSStore.java (Page searchAndFetch(String indexName, Query query, Pageable pageable)):
Sort sort = Sort.by(Direction.ASC, "title"); Pageable pageable = PageRequest.of(0, 1, sort);
Stack trace: `2018-11-20 15:48:51.763 DEBUG 20086 --- [nio-8080-exec-6] c.t.i.i.c.j.w.i.RestIPFSStoreWrapperImpl : Search [indexName=documents, query=Query(filterClauses=[Filter(name=hash, names=[hash], operation=equals, value=QmTqGZV9HQ3ZEPWmpXbaeHBoKoDmGDqwGS1hvDnpBLPiMg)])] 2018-11-20 15:48:51.764 TRACE 20086 --- [nio-8080-exec-6] c.t.i.i.c.j.w.i.RestIPFSStoreWrapperImpl : url=http://ipfs-vbox:8040/ipfs-store/query/search?index=documents 2018-11-20 15:48:51.764 TRACE 20086 --- [nio-8080-exec-6] c.t.i.i.c.j.w.i.RestIPFSStoreWrapperImpl : query=Query(filterClauses=[Filter(name=hash, names=[hash], operation=equals, value=QmTqGZV9HQ3ZEPWmpXbaeHBoKoDmGDqwGS1hvDnpBLPiMg)]) 2018-11-20 15:48:51.802 TRACE 20086 --- [nio-8080-exec-6] c.t.i.i.c.j.w.i.RestIPFSStoreWrapperImpl : result Page 1 of 1 containing net.consensys.tools.ipfs.ipfsstore.dto.Metadata instances 2018-11-20 15:48:51.803 DEBUG 20086 --- [nio-8080-exec-6] c.t.i.i.c.j.w.i.RestIPFSStoreWrapperImpl : Search [indexName=documents, query=Query(filterClauses=[Filter(name=hash, names=[hash], operation=equals, value=QmTqGZV9HQ3ZEPWmpXbaeHBoKoDmGDqwGS1hvDnpBLPiMg)])] : 1 result(s) 2018-11-20 15:48:51.803 DEBUG 20086 --- [nio-8080-exec-6] c.t.i.i.c.j.w.i.RestIPFSStoreWrapperImpl : fetch [indexName=documents, hash=QmTqGZV9HQ3ZEPWmpXbaeHBoKoDmGDqwGS1hvDnpBLPiMg] 2018-11-20 15:48:51.932 DEBUG 20086 --- [nio-8080-exec-6] c.t.i.i.c.j.w.i.RestIPFSStoreWrapperImpl : fetch [indexName=documents, hash=QmTqGZV9HQ3ZEPWmpXbaeHBoKoDmGDqwGS1hvDnpBLPiMg] : <200,[B@5baf19b9,{Content-Type=[application/x-sega-cd-rom], Transfer-Encoding=[chunked], Date=[Tue, 20 Nov 2018 15:14:38 GMT]}> 2018-11-20 15:48:51.935 ERROR 20086 --- [nio-8080-exec-6] n.e.h.b.c.GlobalExceptionHandler : defaultExceptionHandler():java.lang.IllegalArgumentException: Pageable must not be null! at org.springframework.util.Assert.notNull(Assert.java:198) ~[spring-core-5.1.2.RELEASE.jar:5.1.2.RELEASE] at org.springframework.data.domain.Chunk.(Chunk.java:54) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at org.springframework.data.domain.PageImpl.(PageImpl.java:46) ~[spring-data-commons-2.1.2.RELEASE.jar:2.1.2.RELEASE]
at net.consensys.tools.ipfs.ipfsstore.client.java.IPFSStore.searchAndFetch(IPFSStore.java:459) ~[ipfs-store-client-java-v0.1.7.jar:0.1.7]
at net.consensys.tools.ipfs.ipfsstore.client.java.IPFSStore.searchAndFetch(IPFSStore.java:430) ~[ipfs-store-client-java-v0.1.7.jar:0.1.7]
at nl.enshore.hackathon.backend.service.FileService.getMetadataAndPayload(FileService.java:218) ~[classes/:na]`
I used IPFS-store version 0.1.7