Search samples

Basics

Almosts all methods use QueryParams. Here there're some tips about how using it.

VariablesTypeAllow wildcardsRestrictionsDescription

domain

long

No.

Available values:

  • QueryParams.DOCUMENT
  • QueryParams.FOLDER
  • QueryParams.MAIL
  • QueryParams.RECORD

By default the value is set to QueryParams.DOCUMENT.

For searching documents and folders use value:

(QueryParams.DOCUMENT | QueryParams.FOLDER) 

Restricts the search to a node types.

author

String

No.

Value must be a valid userId.

Filters by creator user.

name

String

Yes.

 

Filters by node name.

title

String

Yes.

  Filters by title name.

keywords

Set<String>

Yes.

 

Filters by keywords.

categories

Set<String>

No.

Values should be a category UUID, not use path value.

Filters by categories.

content

 

Yes.

 

Filters by binary content.

mimeType

 

No.

Value should be a valid and registered MIME type.

Only can be applied to documents node.

Filters by document MIME type.

language

 

No.

Value should be a valid language.

Only can be applied to documents node.

Filters by document language.

folder

 

No.

When empty is used by default "/okm:root" node.

Value should be a valid UUID, not use a path value.

Filters by a folder.

folderRecursive

Boolean

No.

Only has sense to set this variable to true when the variable folder is not empty.

Enables filter recursively by a folder.

lastModifiedFrom

Calendar

No.

 

Filters by nodes created after a date.

lastModifiedTo

Calendar

No.

 

Filters by nodes created before a date.

mailSubject

String

Yes.

Only apply to mail nodes.

Filters by mail subject field.

mailFrom

String

Yes.

Only apply to mail nodes.

Filters by mail from field.

mailTo

 

Yes.

Only apply to mail nodes.

Filters by mail to field.

notes

 

Yes.

 

Filters by notes.

properties

Map<String, String>

Yes on almost.

On metadata field values like "date" can not be applied wilcards.

The map of the properties is composed of pairs:

('metadata_field_name','metada_field_value")

For example:

Map<String, String> properties = new HashMap();
properties.put("okp:consulting.name", "name value");

Filtering by range of dates:

Calendar to = Calendar.getInstance(); // today
to.set(0, Calendar.HOUR);
to.set(0, Calendar.MINUTE);
to.set(0, Calendar.SECOND);
to.set(0, Calendar.MILLISECOND);
Calendar from = (Calendar) to.clone();
from.add(-3, Calendar.DATE); // three days before
Map<String,String> properties = new HashMap<>();
properties.put("okp:consulting.date", ISO8601.formatBasic(from)+","+ISO8601.formatBasic(to));

When filtering by range of dates you must set both values ( from and to ), otherwise the filter will be ignored from the  OpenKM side.

To filtering by a metadata field of type multiple like this:

<select label="Multiple" name="okp:consulting.multiple" type="multiple">
  <option label="One" value="one"/>
  <option label="Two" value="two"/>
  <option label="Three" value="three" />
</select>

You should do:

properties.put("okp:consulting.multiple", "one;two");

Where "one" and "two" are valid values and character ";" is used as separator.

Filters by metadata group values.

The search operation is done only by AND logic.

Wildcard examples:

VariableExampleDescription

name

test*.html

Any document that starts with characters "test" and ends with characters ".html"

name

test?.html

Any document that starts with characters "test" followed by a single character and ends with characters ".html"

name

?test*

Any of the documents where the first character doesn't matter, but is followed by the characters, "test".

Suggested code sample

First, you must create the webservice object:

OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

Then should login using the method "login". You can access the "login" method from webservice object "ws" as is shown below:

ws.login(user, password);

Once you are logged with the webservices the session is keep in the webservice Object. Then you can use the other API method

At this point you can use all the Search methods from "search" class as is shown below:

ws.search.find(qParams, null)

Methods

find

Description:

MethodReturn valuesDescription

find(QueryParams queryParams, String propertiesPlugin)

List<QueryResult>

Returns a list of results filtered by the values of the queryParams parameter.

The parameter "propertiesPlugin" must be a canonical class name of the class which implements the NodeProperties interface.

Retrieving entire Objects ( Document, Folder, Record, Mail ) from REST can take a lot of time - marshalling and unmarshalling process - while you are only interesting on using only few Objects variables. If its your case you can use NodeProperties classes for retrieving the Object variables what you really need.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.QueryParams;
import com.openkm.sdk4j.bean.QueryResult;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            QueryParams qParams = new QueryParams();
            qParams.setDomain(QueryParams.DOCUMENT + QueryParams.FOLDER);
            qParams.setName("test*");

            for (QueryResult qr : ws.search.find(qParams, null)) {
                System.out.println(qr);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

findPaginated

Description:

MethodReturn valuesDescription

findPaginated(QueryParams queryParams, int offset, int limit, String propertiesPlugin)

ResultSet

Returns a list of paginated results filtered by the values of the queryParams parameter.

The parameter "limit" and "offset" allows you to retrieve just a portion of the results of a query.

  • The parameter "limit" is used to limit the number of results returned.
  • The parameter "offset" says to skip that many results before the beginning to return results.

The parameter "propertiesPlugin" must be the canonical class name of the class which implements the NodeProperties interface.

For example if your query has 1000 results, but you only want to return the first 10, you should use these values:

  • limit=10
  • offset=0

Now suppose you want to show the results from 11-20, you should use these values:

  • limit=10
  • offset=10

Retrieving entire Objects ( Document, Folder, Record, Mail ) from REST can take a lot of time - marshalling and unmarshalling process - while you are only interesting on using only few Objects variables. If its your case you can use NodeProperties classes for retrieving the Object variables what you really need.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.QueryParams;
import com.openkm.sdk4j.bean.QueryResult;
import com.openkm.sdk4j.bean.ResultSet;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            QueryParams qParams = new QueryParams();
            qParams.setDomain(QueryParams.DOCUMENT + QueryParams.FOLDER);
            qParams.setName("test*");
            ResultSet rs = ws.search.findPaginated(qParams, 20, 10, null);
            System.out.println("Total results: " + rs.getTotal());

            for (QueryResult qr : rs.getResults()) {
                System.out.println(qr);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

findSimpleNodeBasePaginated

Description:

MethodReturn valuesDescription

findSimpleNodeBasePaginated(QueryParams queryParams, int offset, int limit)

SimpleNodeBaseResultSet

Returns a list of SimpleNodeBase paginated results filtered by the values of the queryParams parameter.

Because the results of the findSimpleNodeBasePaginated method are objects of type SimpleNodeBase, this method is about 60-70% faster than the other search methods ( these metrics should be taken as orientative values because depends on hardware and the specific scenario where application is running). The other search methods returns objects of type Node what comes with a full node data, the SimpleNodeBase object provide less data but in almost cases should be enought. Specially when the limit is a higher value you will appreciate the difference in the perfomance.

The parameter "limit" and "offset" allows you to retrieve just a portion of the results of a query.

  • The parameter "limit" is used to limit the number of results returned.
  • The parameter "offset" says to skip that many results before the beginning to return results.

For example if your query has 1000 results, but you only want to return the first 10, you should use these values:

  • limit=10
  • offset=0

Now suppose you want to show the results from 11-20, you should use these values:

  • limit=10
  • offset=10

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.*;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            QueryParams qParams = new QueryParams();
            qParams.setDomain(QueryParams.DOCUMENT + QueryParams.FOLDER);
            qParams.setName("test*");
            SimpleNodeBaseResultSet rs = ws.search.findSimpleNodeBasePaginated(qParams, 20, 10);
            System.out.println("Total results: " + rs.getTotal());

            for (SimpleNodeBase sn : rs.getResults()) {
                System.out.println(sn);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getKeywordMap

Description:

MethodReturn valuesDescription

getKeywordMap(List<String> filter)

Map<String, Integer>

Returns a map of keywords with its count value filtered by other keywords.

Example:

  • Doc1.txt has keywords "test", "one", "two".
  • Doc2.txt has keywords "test", "one"
  • Doc3.txt has keywords "test", "three".

The results filtering by "test" -> "one", "two", "three".

The results filtering by "one" -> "test", "two".

The results filtering by "two" -> "test", "one".

The results filtering by "three" -> "test".

The results filtering by "one" and "two" -> "test".

 

Example:

package com.openkm;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            // All keywords without filtering
            System.out.println("Without filtering");
            Map<String, Integer> keywords = ws.getKeywordMap(new ArrayList<String>());

            for (String key : keywords.keySet()) {
                System.out.println(key + " is used :" + keywords.get(key));
            }

            // Keywords filtered
            System.out.println("Filtering");
            keywords = ws.search.getKeywordMap(Arrays.asList("test"));

            for (String key : keywords.keySet()) {
                System.out.println(key + " is used :" + keywords.get(key));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getCategorizedDocuments

Description:

MethodReturn valuesDescription

getCategorizedDocuments(String categoryId)

List<Document>

Retrieves a list of all documents related with a category.

The values of the categoryId parameter should be a category folder UUID.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Document;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            for (Document doc : ws.search.getCategorizedDocuments("58c9b25f-d83e-4006-bd78-e26d7c6fb648")) {
                System.out.println(doc);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

findByQueryPaginated

Description:

MethodReturn valuesDescription

findByQueryPaginated(String query, int offset, int limit, String propertiesPlugin)

ResultSet

Returns a list of paginated results filtered by the values of the query parameter.

The syntax to use in the statement parameter is the pair 'field:value'. For example:

  • "name:grial" is filtering field name by word grial.

More information about lucene sintaxis at Lucene query syntax.

The parameter "limit" and "offset" allows you to retrieve just a portion of the results of a query.

  • The parameter "limit" is used to limit the number of results returned.
  • The parameter "offset" says to skip that many results before the beginning to return results.
  • The parameter "propertiesPlugin" must be the canonical class name of the class which implements the NodeProperties interface.

For example if your query has 1000 results, but you only want to return the first 10, you should use these values:

  • limit=10
  • offset=0

Now suppose you want to show the results from 11-20, you should use these values:

  • limit=10
  • offset=10

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.QueryResult;
import com.openkm.sdk4j.bean.ResultSet;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            ResultSet rs = ws.search.findByQueryPaginated("text:grial AND name:t*.pdf", 0, 10, null);
            System.out.println("Total results:" + rs.getTotal());

            for (QueryResult qr : rs.getResults()) {
                System.out.println(qr);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

findSimpleNodeBaseByQueryPaginated

Description:

MethodReturn valuesDescription

findSimpleNodeBaseByQueryPaginated(String query, int offset, int limit)

SimpleNodeBaseResultSet

Returns a list of paginated results filtered by the values of the query parameter.

The syntax to use in the statement parameter is the pair 'field:value'. For example:

  • "name:grial" is filtering field name by word grial.

More information about lucene sintaxis at Lucene query syntax.

The parameter "limit" and "offset" allows you to retrieve just a portion of the results of a query.

  • The parameter "limit" is used to limit the number of results returned.
  • The parameter "offset" says to skip that many results before the beginning to return results.

For example if your query has 1000 results, but you only want to return the first 10, you should use these values:

  • limit=10
  • offset=0

Now suppose you want to show the results from 11-20, you should use these values:

  • limit=10
  • offset=10

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.SimpleNodeBase;
import com.openkm.sdk4j.bean.SimpleNodeBaseResultSet;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            SimpleNodeBaseResultSet result = ws.search.findSimpleNodeBaseByQueryPaginated("text:grial AND name:t*.pdF", 0, 10);
            for (SimpleNodeBase nodeBase : result.getResults()) {
                if (nodeBase != null) {
                    System.out.println(nodeBase.toString());
                }
            }
            System.out.println("Total: " + result.getTotal());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

saveSearch

Description:

MethodReturn valuesDescription

saveSearch(QueryParams params)

Long

Saves a search parameters.

The variable queryName of the parameter params, should have to be initialized.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.QueryParams;
import com.openkm.sdk4j.bean.QueryResult;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            QueryParams qParams = new QueryParams();
            qParams.setDomain(QueryParams.DOCUMENT + QueryParams.FOLDER);
            qParams.setName("test*");
            for (QueryResult qr : ws.find(qParams, null)) {
                System.out.println(qr);
            }
            // Save the search to be used later
            qParams.setQueryName("sample search");
            ws.search.saveSearch(qParams);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

updateSearch

Description:

MethodReturn valuesDescription

updateSearch(QueryParams params)

void

Updates a previously saved search parameters.

Only can be updated as a saved search created by the same user user who's executing the method.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.QueryParams;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            for (QueryParams qParams : ws.getAllSearchs()) {
                if (qParams.getQueryName().equals("sample search")) {
                    // Change some value.
                    qParams.setName("admin*.html");
                    ws.search.updateSearch(qParams);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getSearch

Description:

MethodReturn valuesDescription

getSearch(int qpId)

QueryParams

Gets saved search parameters.

Only can be retrieved as a saved search created by the same user who's executing the method.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.QueryParams;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            int qpId = 1; // Some valid search id
            QueryParams qParams = ws.search.getSearch(qpId);
            System.out.println(qParams);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getAllSearchs

Description:

MethodReturn valuesDescription

getAllSearchs()

List<QueryParams>

Retrieves a list of all saved search parameters.

Only will be retrieved the list of the saved searches created by the same user who's executing the method.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.QueryParams;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            for (QueryParams qParams : ws.search.getAllSearchs()) {
                System.out.println(qParams);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

deleteSearch

Description:

MethodReturn valuesDescription

deleteSearch(int qpId)

void

Deletes a saved search parameters.

Only can be deleted as a saved search created by the same user user who's executing the method.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            int qpId = 1; // Some valid search id
            ws.search.deleteSearch(qpId);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

findAllDefaultByNodeClass

Description:

MethodReturn valuesDescription

findAllDefaultByNodeClass(long ncId)

List<QueryParams>

Retrieve a list of saved searches of a NodeClass

Example:

package com.openkm;

import java.util.List;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.QueryParams;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            long ncId = 1;
            List<QueryParams> results = ws.search.findAllDefaultByNodeClass(ncId);
            for (QueryParams params : results) {
                System.out.println(params);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

findByQuery

Description:

MethodReturn valuesDescription

findByQuery(String query, String propertiesPlugin)

List<QueryResult>

Returns a list of results filtered by the query parameter.

The syntax to use in the statement parameter is the pair 'field:value'. For example:

  • "name:grial" is filtering field name by word grial.

More information about lucene sintaxis at Lucene query syntax.

The parameter "propertiesPlugin" must be the canonical class name of the class which implements the NodeProperties interface.

Example:

package com.openkm;

import java.util.List;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.QueryResult;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            List<QueryResult> results = ws.search.findByQuery("keyword:test AND name:t*.pdf", null);            

            for (QueryResult qr : results) {
                System.out.println(qr);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

findWithMetadata

Description:

MethodReturn valuesDescription

findWithMetadata(QueryParams queryParams, String propertiesPlugin, List<String> groups)

List<QueryResult>

Returns a list of results with metadata values filtered by the queryParams parameter.

  • The parameter "propertiesPlugin" must be a canonical class name of the class which implements the NodeProperties interface.
  • The parameter "groups" must be valid metadata group names.

Retrieving entire Objects ( Document, Folder, Record, Mail ) from REST can take a lot of time - marshalling and unmarshalling process - while you are only interesting on using only few Objects variables. If its your case you can use NodeProperties classes for retrieving the Object variables what you really need.

Example:

package com.openkm;

import java.util.ArrayList;
import java.util.List;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.QueryParams;
import com.openkm.sdk4j.bean.QueryResult;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            QueryParams qParams = new QueryParams();
            qParams.setDomain(QueryParams.DOCUMENT + QueryParams.FOLDER);
            qParams.setName("test*");

            List<String> groups = new ArrayList<>();
            groups.add("okg:consulting");

            for (QueryResult qr : ws.search.findWithMetadata(qParams, null, groups)) {
                System.out.println(qr);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

findWithMedataPaginated

Description:

MethodReturn valuesDescription

findWithMetadataPaginated(QueryParams queryParams, int offset, int limit, String propertiesPlugin, List<String> groups)

ResultSet

Returns a list of paginated results with metadata values filtered by the queryParams parameter.

The parameter "limit" and "offset" allows you to retrieve just a portion of the results of a query.

  • The parameter "limit" is used to limit the number of results returned.
  • The parameter "offset" says to skip that many results before the beginning to return results.
  • The parameter "propertiesPlugin" must be the canonical class name of the class which implements the NodeProperties interface.
  • The parameter "groups" must be valid metadata group names.

For example if your query has 1000 results, but you only want to return the first 10, you should use these values:

  • limit=10
  • offset=0

Now suppose you want to show the results from 11-20, you should use these values:

  • limit=10
  • offset=10

Retrieving entire Objects ( Document, Folder, Record, Mail ) from REST can take a lot of time - marshalling and unmarshalling process - while you are only interesting on using only few Objects variables. If its your case you can use NodeProperties classes for retrieving the Object variables what you really need.

Example:

package com.openkm;

import java.util.ArrayList;
import java.util.List;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.QueryParams;
import com.openkm.sdk4j.bean.QueryResult;
import com.openkm.sdk4j.bean.ResultSet;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            QueryParams qParams = new QueryParams();
            qParams.setDomain(QueryParams.DOCUMENT + QueryParams.FOLDER);
            qParams.setName("test*");

            List<String> groups = new ArrayList<>();
            groups.add("okg:consulting");

            ResultSet rs = ws.search.findWithMetadataPaginated(qParams, 0, 10, null, groups);
            System.out.println("Total results: " + rs.getTotal());

            for (QueryResult qr : rs.getResults()) {
                System.out.println(qr);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getMimeTypes

Description:

MethodReturn valuesDescription

getMimeTypes()

List<MimeType>

Retrieves a list of mimetypes.

Only will be retrieved the list of the mimeTypes what may be used in the search.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.MimeType;
import com.openkm.sdk4j.impl.OKMWebservices;

public class Test {

    public static void main(String[] args) {
        String host = "http://localhost:8080/openkm";
        String user = "okmAdmin";
        String password = "admin";
        OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

        try {
            ws.login(user, password);
            for (MimeType mimeType : ws.search.getMimeTypes()) {
                System.out.println(mimeType);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}