• Find documents by SDK not working properly

  • We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
We tried to make OpenKM as intuitive as possible, but an advice is always welcome.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #29455  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!
 #29475  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.
 #29484  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?
 #29629  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?
 #29641  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();
	}
}
 #29657  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!

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.