OKMProperty

Basics

On most methods you'll see a parameter named "nodeId". The value of this parameter can be a valid document, folder, mail, or record UUID.

Example of nodeId:

  • Using UUID -> "b153c4b7-3d1c-4589-bd42-0ed0f34fd338";

About the parameter named "catId", the value of this parameter can be a valid category folder UUID node.

Example of nodeId:

  • Using UUID -> "5cbc35fc-23c0-48f5-a7bc-3cfa1e7be25f";

Also, on all methods you'll see a parameter named "token". Because cron tasks are executed in the background without authentication, the methods used in this scenario might use the token parameter. From the default application execution context you must use the value "null", which indicates that the application must use the "user session".

In special cases you might be "promoted as Administrator" using the "administrator token".

String systemToken = DbSessionManager.getInstance().getSystemToken();

Methods

addCategory

Description:

MethodReturn valuesDescription

addCategory(String token, String nodeId, String catId)

void

Sets a relation between a category and a node.

The value of the catId parameter should be a category folder UUID. 

Example:

package com.openkm;

import com.openkm.api.OKMProperty;
import com.openkm.util.ContextWrapper;

public class Test {

    public static void main(String[] args) {
        try {
            OKMProperty okmProperty = ContextWrapper.getContext().getBean(OKMProperty.class);
            okmProperty.addCategory(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "5cbc35fc-23c0-48f5-a7bc-3cfa1e7be25f");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

removeCategory

Description:

MethodReturn valuesDescription

removeCategory(String token, String nodeId, String catId)

void

Removes a relation between a category and a node.

The value of the catId parameter should be a category folder UUID. 

Example:

package com.openkm;

import com.openkm.api.OKMProperty;
import com.openkm.util.ContextWrapper;

public class Test {

    public static void main(String[] args) {
        try {
            OKMProperty okmProperty = ContextWrapper.getContext().getBean(OKMProperty.class);
            okmProperty.removeCategory(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "5cbc35fc-23c0-48f5-a7bc-3cfa1e7be25f");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

addKeyword

Description:

MethodReturn valuesDescription

addKeyword(String token, String nodeId, String keyword)

String

Adds a keyword to a node.

The keyword should be a single word without spaces, formats allowed:

  • "test"
  • "two_words" (the character "_" is used for joining).

We also suggest that you add keywords in lowercase, because OpenKM is case sensitive.

Example:

package com.openkm;

import com.openkm.api.OKMProperty;
import com.openkm.util.ContextWrapper;

public class Test {

    public static void main(String[] args) {
        try {
            OKMProperty okmProperty = ContextWrapper.getContext().getBean(OKMProperty.class);
            String keyword = okmProperty.addKeyword(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "test");
            System.out.println(keyword);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

removeKeyword

Description:

MethodReturn valuesDescription

removeKeyword(String token, String nodeId, String keyword)

void

Removes a keyword from a node.

Example:

package com.openkm;

import com.openkm.api.OKMProperty;
import com.openkm.util.ContextWrapper;

public class Test {

    public static void main(String[] args) {
        try {
            OKMProperty okmProperty = ContextWrapper.getContext().getBean(OKMProperty.class);
            okmProperty.removeKeyword(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "test");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

setSigned

Description:

MethodReturn valuesDescription

setSigned(String token, String nodeId, boolean signed)

void

Marks a document as signed or unsigned in the repository.

The parameter nodeId should be a document node.

This method does not perform any kind of digital signature process; it simply marks in the database that a document is signed.

Example:

package com.openkm;

import com.openkm.api.OKMProperty;
import com.openkm.util.ContextWrapper;

public class Test {

    public static void main(String[] args) {
        try {
            OKMProperty okmProperty = ContextWrapper.getContext().getBean(OKMProperty.class);
            okmProperty.setSigned(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", true);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

isSigned

Description:

MethodReturn valuesDescription

isSigned(String token, String nodeId)

boolean

Returns a boolean that indicates whether the document is signed.

The parameter nodeId should be a document node.

This method was added in OpenKM version 7.1.28.

Example:

package com.openkm;

import com.openkm.api.OKMProperty;
import com.openkm.util.ContextWrapper;

public class Test {

    public static void main(String[] args) {
        try {
            OKMProperty okmProperty = ContextWrapper.getContext().getBean(OKMProperty.class);
            System.out.println("Is the document signed: " + okmProperty.isSigned(null, "6330d2a0-529f-4c14-baa1-ce6a92004e01"));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}