Node samples

Basics

Example of uuid:

  • Using UUID -> "373bcdd0-c082-4e7b-addd-e10ef813946e";

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 Node methods from "node" class as is shown below:

ws.node.getNodeByUuid("29a22996-0e3b-421e-8759-c24ea41c1ebb")

Methods

getNodeByUuid

Description:

MethodReturn valuesDescription

getNodeByUuid(String uuid)

Node

Get a node by uuid.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Node;
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);
            Node node = ws.node.getNodeByUuid("29a22996-0e3b-421e-8759-c24ea41c1ebb");
            System.out.println(node);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getVersionHistory

Description:

MethodReturn valuesDescription

getVersionHistory(String uuid)

List<Version>

Returns a list of the version history of a document.

Example:

package com.openkm;

import java.util.List;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Version;
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<Version> versions = ws.node.getVersionHistory("3767deb4-21e7-4272-82be-fece5384fbab");
            for (Version version : versions) {
                System.out.println(version);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

restoreVersion

Description:

MethodReturn valuesDescription

restoreVersion(String uuid, String versionName)

void

Restore a document to a specific version.

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);
            ws.node.restoreVersion("3767deb4-21e7-4272-82be-fece5384fbab", "1.2");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

deleteVersion

Description:

MethodReturn valuesDescription

deleteVersion(String uuid, String versionName)

void

Delete a specific version.

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);
            ws.node.deleteVersion("5aab162d-df4f-4392-96c9-8fc1607e3903", "1.1");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

purgeVersionHistory

Description:

MethodReturn valuesDescription

purgeVersionHistory(String uuid)

void

Purge version history of a document.

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);
            ws.node.purgeVersionHistory("3767deb4-21e7-4272-82be-fece5384fbab");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

mayBePromotedAsRecord

Description:

MethodReturn valuesDescription

mayBePromotedAsRecord(String uuid, boolean fullEvaluation)

PromoteAsRecordEvaluation

Returns a PromoteAsRecordEvaluation object.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.PromoteAsRecordEvaluation;
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);
            PromoteAsRecordEvaluation pre = ws.node.mayBePromotedAsRecord("3767deb4-21e7-4272-82be-fece5384fbab", false);
            System.out.println(pre);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

promoteAsRecord

Description:

MethodReturn valuesDescription

promoteAsRecord(String uuid)

void

Promote as record.

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);
            ws.node.promoteAsRecord("3767deb4-21e7-4272-82be-fece5384fbab");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

degradeRecord

Description:

MethodReturn valuesDescription

degradeRecord(String uuid)

void

Degrade a record.

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);
            ws.node.degradeRecord("3767deb4-21e7-4272-82be-fece5384fbab");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

isElectronicRecordPath

Description:

MethodReturn valuesDescription

isElectronicRecordPath(String uuid)

boolean

Returns true when the node is into an electronic record.

Return true when one of the parents of the node is an electronic record.

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);
            System.out.println(ws.node.isElectronicRecordPath("3767deb4-21e7-4272-82be-fece5384fbab"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getElectronicRecordInPath

Description:

MethodReturn valuesDescription

getElectronicRecordInPath(String uuid)

Record

Get the electronic record in the path.

Returns the first electronic record in the path of the node.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Record;
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);
            Record record = ws.node.getElectronicRecordInPath("3767deb4-21e7-4272-82be-fece5384fbab");
            System.out.println(record);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getChildrenNodesPaginated

Description:

MethodReturn valuesDescription

getChildrenNodesPaginated(String uuid, int offset, int limit, String filter, String orderByField, boolean orderAsc, List<Integer> filteredTypes)

SimpleNodeBaseList

Get children nodes paginated.

Available filteredTypes values:

SimpleNodeBase.TYPE_FOLDER
SimpleNodeBase.TYPE_DOCUMENT
SimpleNodeBase.TYPE_MAIL
SimpleNodeBase.TYPE_RECORD

You should do:

List<Integer> filteredTypes = new ArrayList<>();
filteredTypes.add(SimpleNodeBase.TYPE_FOLDER);
filteredTypes.add(SimpleNodeBase.TYPE_DOCUMENT);

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.NodesPaginationInfo;
import com.openkm.sdk4j.bean.SimpleNodeBase;
import com.openkm.sdk4j.bean.SimpleNodeBaseList;
import com.openkm.sdk4j.impl.OKMWebservices;

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

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<Integer> filteredTypes = new ArrayList<>();
            filteredTypes.add(SimpleNodeBase.TYPE_FOLDER);
            filteredTypes.add(SimpleNodeBase.TYPE_DOCUMENT);
            // Folder UUID or Record UUID
            String uuid = "39479efe-de5e-468e-91a7-24d2aa3f8837";
            SimpleNodeBaseList listNode = ws.node.getChildrenNodesPaginated(uuid, 0, 10, "", NodesPaginationInfo.ORDER_BY_NAME, true,
                    filteredTypes);
            System.out.println("Filtered Elements: " + listNode.getFilteredElements());
            System.out.println("Total Elements: " + listNode.getTotalElements());
            for (SimpleNodeBase simpleNodeBase : listNode.getNodes()) {
                System.out.println(simpleNodeBase.getPath());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getChildrenNodesPaginated

Description:

MethodReturn valuesDescription

getChildrenNodesPaginated(String uuid, int offset, int limit, String filter, String orderByField, boolean orderAsc, List<Integer> filteredTypes, String pluginName)

SimpleNodeBaseList

Get children nodes paginated.

Available filteredTypes values:

SimpleNodeBase.TYPE_FOLDER
SimpleNodeBase.TYPE_DOCUMENT
SimpleNodeBase.TYPE_MAIL
SimpleNodeBase.TYPE_RECORD

You should do:

List<Integer> filteredTypes = new ArrayList<>();
filteredTypes.add(SimpleNodeBase.TYPE_FOLDER);
filteredTypes.add(SimpleNodeBase.TYPE_DOCUMENT);

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

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.NodesPaginationInfo;
import com.openkm.sdk4j.bean.SimpleNodeBase;
import com.openkm.sdk4j.bean.SimpleNodeBaseList;
import com.openkm.sdk4j.impl.OKMWebservices;

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

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<Integer> filteredTypes = new ArrayList<>();
            filteredTypes.add(SimpleNodeBase.TYPE_FOLDER);
            filteredTypes.add(SimpleNodeBase.TYPE_DOCUMENT);
            // Folder UUID or Record UUID
            String uuid = "39479efe-de5e-468e-91a7-24d2aa3f8837";
            SimpleNodeBaseList listNode = ws.node.getChildrenNodesPaginated(uuid, 0, 10, "", NodesPaginationInfo.ORDER_BY_NAME, true,
                    filteredTypes, "");
            System.out.println("Filtered Elements: " + listNode.getFilteredElements());
            System.out.println("Total Elements: " + listNode.getTotalElements());
            for (SimpleNodeBase simpleNodeBase : listNode.getNodes()) {
                System.out.println(simpleNodeBase.getPath());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getChildrenNodesByCategoryPaginated

Description:

MethodReturn valuesDescription

getChildrenNodesByCategoryPaginated(String uuid, int offset, int limit, String filter, String orderByField, boolean orderAsc, List<Integer> filteredTypes)

SimpleNodeBaseList

Get children nodes by category paginated.

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.NodesPaginationInfo;
import com.openkm.sdk4j.bean.SimpleNodeBase;
import com.openkm.sdk4j.bean.SimpleNodeBaseList;
import com.openkm.sdk4j.impl.OKMWebservices;

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

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<Integer> filteredTypes = new ArrayList<>();
            filteredTypes.add(1);
            // Folder UUID or Record UUID
            String uuid = "39479efe-de5e-468e-91a7-24d2aa3f8837";
            SimpleNodeBaseList listNode = ws.node.getChildrenNodesByCategoryPaginated(uuid, 0, 10, "", NodesPaginationInfo.ORDER_BY_NAME, true,
                    filteredTypes);
            System.out.println("Filtered Elements: " + listNode.getFilteredElements());
            System.out.println("Total Elements: " + listNode.getTotalElements());
            for (SimpleNodeBase simpleNodeBase : listNode.getNodes()) {
                System.out.println(simpleNodeBase.getPath());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getChildrenNodesByCategoryPaginated

Description:

MethodReturn valuesDescription

getChildrenNodesByCategoryPaginated(String uuid, int offset, int limit, String filter, String orderByField, boolean orderAsc, List<Integer> filteredTypes, String pluginName)

SimpleNodeBaseList

Get children nodes by category paginated.

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.NodesPaginationInfo;
import com.openkm.sdk4j.bean.SimpleNodeBase;
import com.openkm.sdk4j.bean.SimpleNodeBaseList;
import com.openkm.sdk4j.impl.OKMWebservices;

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

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<Integer> filteredTypes = new ArrayList<>();
            filteredTypes.add(1);
            // Folder UUID or Record UUID
            String uuid = "39479efe-de5e-468e-91a7-24d2aa3f8837";
            SimpleNodeBaseList listNode = ws.node.getChildrenNodesByCategoryPaginated(uuid, 0, 10, "", NodesPaginationInfo.ORDER_BY_NAME, true,
                    filteredTypes, "");
            System.out.println("Filtered Elements: " + listNode.getFilteredElements());
            System.out.println("Total Elements: " + listNode.getTotalElements());
            for (SimpleNodeBase simpleNodeBase : listNode.getNodes()) {
                System.out.println(simpleNodeBase.getPath());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getBreadcrumb

Description:

MethodReturn valuesDescription

getBreadcrumb(String uuid)

List<BreadCrumbItem>

Get breadcrumb.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.BreadCrumbItem;
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<BreadCrumbItem> list = ws.node.getBreadcrumb("39479efe-de5e-468e-91a7-24d2aa3f8837");
            for (BreadCrumbItem item : list) {
                System.out.println(item.getPath());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

subscribe

Description:

MethodReturn valuesDescription

subscribe(String uuid)

void

Adds a subscription to a node.

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);
            ws.node.subscribe("39479efe-de5e-468e-91a7-24d2aa3f8837");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

unsubscribe

Description:

MethodReturn valuesDescription

unsubscribe(String uuid)

void

Delete a subscription to a node.

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);
            ws.node.unsubscribe("39479efe-de5e-468e-91a7-24d2aa3f8837");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

importZip

Description:

MethodReturn valuesDescription

importZip(String uuid, InputStream is)

void

Import a zip file.

Example:

package com.openkm;

import java.io.FileInputStream;
import java.io.InputStream;

import org.apache.commons.io.IOUtils;

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);
            InputStream is = new FileInputStream("/home/gnujavasergio/okm/import.zip");
            ws.node.importZip("212e7c1f-443d-4aac-a12c-0b818ca03419", is);
            IOUtils.closeQuietly(is);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

unZip

Description:

MethodReturn valuesDescription

unZip(String uuid, String dstId)

void

Unzip file.

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);
            String uuid = "82555dd1-bcc2-4e64-81cb-5f7c2b0d7801"; // zip File
            String dstId = "70ec54af-76ad-4d02-b9c8-8c94c3b6ffc7"; // destination uuid
            ws.node.unZip(uuid, dstId);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

exportZip

Description:

MethodReturn valuesDescription

exportZip(List<String> uuids, boolean withPath, boolean background)

InputStream

Export as a zip file.

Example:

package com.openkm;

import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.io.IOUtils;

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);
            List<String> uuids = new ArrayList<>();
            uuids.add("0f6463f3-4d36-4091-b518-4fe7c353ee70");
            uuids.add("d386cff8-1d4d-472f-9c6d-f21955ec499a");

            OutputStream fos = new FileOutputStream("/home/openkm/export.zip");

            InputStream is = ws.node.exportZip(uuids, true, true);
            IOUtils.copy(is, fos);
            IOUtils.closeQuietly(is);
            IOUtils.closeQuietly(fos);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getNodesFiltered

Description:

MethodReturn valuesDescription

getNodesFiltered(List<String> uuids)

List<Node>

Return a list of nodes.

Example:

package com.openkm;

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

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Node;
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<String> uuids = new ArrayList<>();
            uuids.add("0f6463f3-4d36-4091-b518-4fe7c353ee70");
            uuids.add("d386cff8-1d4d-472f-9c6d-f21955ec499a");

            List<Node> nodes = ws.node.getNodesFiltered(uuids);
            for (Node node : nodes) {
                System.out.println(node);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

evaluateDownloadZip

Description:

MethodReturn valuesDescription

evaluateDownloadZip(List<String> uuids)

ZipDownloadEvaluationResult

Return a ZipDownloadEvaluationResult object.

Example:

package com.openkm;

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

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.ZipDownloadEvaluationResult;
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<String> uuids = new ArrayList<>();
            uuids.add("0f6463f3-4d36-4091-b518-4fe7c353ee70");
            uuids.add("d386cff8-1d4d-472f-9c6d-f21955ec499a");

            ZipDownloadEvaluationResult result = ws.node.evaluateDownloadZip(uuids);
            System.out.println(result);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

generateDownloadToken

Description:

MethodReturn valuesDescription

generateDownloadToken(String uuid, boolean preview)

String

Generate a node download link.

When parameter preview is set to true, the token will be generated for previewing purpose.

The preview token expires by default in a minute.

The user must build the download URL with the returned token:

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);
            System.out.println(ws.node.generateDownloadToken("b2f88679-e3fd-4f97-bf0e-abf76f9ec499", true));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
} 

restore

Description:

MethodReturn valuesDescription

restore(String uuid)

Node

Restore a node

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Node;
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);
            Node node = ws.node.restore("0f6463f3-4d36-4091-b518-4fe7c353ee70");
            System.out.println(node);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

hasNodesLockedByOtherUser

Description:

MethodReturn valuesDescription

hasNodesLockedByOtherUser(String uuid)

booelan

If the node is blocked by other users

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);
            if(ws.node.hasNodesLockedByOtherUser("0f6463f3-4d36-4091-b518-4fe7c353ee70")) {
            	System.out.println("Is blocked");
            }                        
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

setComment

Description:

MethodReturn valuesDescription

setComment(String uuid, String versionName, String comment)

void

Sets the comment for a specific node version.

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);
            ws.node.setComment("1ec49da9-1746-4875-ae32-9281d7303a62", "1.14", "Update comment");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}