Page 1 of 1

Find documents by SDK not working properly

PostPosted:Thu Jul 31, 2014 7:39 am
by Catscratch
Hi,

my aim is to find all documents in a specific folder and do this paginated.

Therefor I want to use the SDK method "findPaginated". This method gets a parameter QueryParams. I used setPath on the QueryParams to set the path.

The result is null everytime. So I started to investigate the REST endpoint which is called by the SDK. It looks like this (without annotations).
Code: Select all
public ResultSet findPaginated(int offset, int limit, String content, String name, int domain, List<String> keywords, List<String> categories, List<String> properties, String author, String mimeType, String lastModifiedFrom, String lastModifiedTo, String mailSubject, String mailFrom, String mailTo)
So you can see, there is no path left. The path in QueryParams is set to null in the REST endpoint.

My question is, why? Why can I specify a path in QueryParams that is never used for a query. And how may I get all documents of a specific folder with pagination?
And yes, we need pagination, because a folder can contain thousands of documents.

Thank you!

Re: Find documents by SDK not working properly

PostPosted:Sun Aug 03, 2014 9:03 am
by jllort
Seems we've missed adding parameter path. We will add and do a new release of the SDK. But without it your query should also going right, except you can not restrict results from some folder no ? this is the problem.

Re: Find documents by SDK not working properly

PostPosted:Sun Aug 03, 2014 1:29 pm
by Catscratch
Right, that's the problem. :-)

But you also have to extend the REST endpoint, because there is no folder parameter, too. Or the SDK does some other tricky thing to put the folder to the server. But I thought the SDK simply uses the REST endpoint, right?

Re: Find documents by SDK not working properly

PostPosted:Wed Aug 06, 2014 4:43 pm
by jllort
I must add a parameter ( path ) which we've forgotten to include here.

Re: Find documents by SDK not working properly

PostPosted:Fri Aug 22, 2014 9:43 am
by Catscratch
Hi,

I got a new question regarding the find-method.
Code: Select all
List<QueryResult> results = okm.find(params);
System.out.println("-> " + results.size());
for (QueryResult queryResult : results) {
	System.out.println(queryResult.getNode());
}
Output:
Code: Select all
-> 2
null
null
The output size is 2 in this case. But getNode() always returns "null" for every queryResult. I also debugged the Rest endpoint and there, everything is ok. Documents are returned inside the QueryResults. Than it goes back to the SDK and the SDK delivers "null" for getNode.

Do you have any idea, what is going wrong here? Is it maybe a bug of the SDK that the QueryResult conversation is not working?

Re: Find documents by SDK not working properly

PostPosted:Sun Aug 24, 2014 7:39 am
by jllort
I suspect you're using wrong SDK version, because method getNode is available from Webservices version 2.0 and you should webservices version 1.0. take a look at compatibility table http://wiki.openkm.com/index.php/SDK_for_Java . The QueryResult.java class in version 1.0 is like:
Code: Select all
public class QueryResult implements Serializable {
	private static final long serialVersionUID = -6397099389620834328L;
	private Document document;
	private Folder folder;
	private String excerpt;
	private long score;
	
	
	public Document getDocument() {
		return document;
	}

	public void setDocument(Document document) {
		this.document = document;
	}

	public Folder getFolder() {
		return folder;
	}

	public void setFolder(Folder folder) {
		this.folder = folder;
	}

	public String getExcerpt() {
		return excerpt;
	}
	
	public void setExcerpt(String excerpt) {
		this.excerpt = excerpt;
	}
	
	public long getScore() {
		return score;
	}
	
	public void setScore(long score) {
		this.score = score;
	}
	
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("{");
		sb.append("document=");
		sb.append(document);
		sb.append(", folder=");
		sb.append(folder);
		sb.append(", excerpt=");
		sb.append(excerpt);
		sb.append(", score=");
		sb.append(score);
		sb.append("}");
		return sb.toString();
	}
}

Re: Find documents by SDK not working properly

PostPosted:Mon Aug 25, 2014 6:26 am
by Catscratch
Hi,

I took the SDK file from here: http://wiki.openkm.com/index.php/File:Sdk4j-ws-1.0.jar

It is named "1.0". But I you take a look into the QueryResult.class you'll find the method getNode instead of getDocument. Same for the 1.0 version in the maven repository. So it seems, something is wrong here. Maybe you packaged the 2.0 as 1.0? Can you please double check?

Thanks!

Re: Find documents by SDK not working properly

PostPosted:Wed Aug 27, 2014 7:13 am
by jllort
I've changed the wiki sdk and this morning we will proceed to change what is in maven repository.