OKMProperty
Basics
In 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";
For 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, in 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 "null" value, which indicates the application must use the "user session".
In special cases you might be "promoted to Administrator" using the "administrator token".
String systemToken = DbSessionManager.getInstance().getSystemToken();
Methods
addCategory
Description:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
Method | Return values | Description |
---|---|---|
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:
We also suggest you add keywords in lowercase format, 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:
Method | Return values | Description |
---|---|---|
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();
}
}
}
setEncryption
Description:
Method | Return values | Description |
---|---|---|
setEncryption(String token, String nodeId, String cipherName) |
void |
Marks a document as encrypted binary data in the repository. |
The parameter nodeId should be a document node. The parameter cipherName saves information about the encryption mechanism. This method does not perform any kind of encryption; it simply marks in the database that a document is encrypted. |
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.setEncryption(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338", "phrase");
} catch (Exception e) {
e.printStackTrace();
}
}
}
unsetEncryption
Description:
Method | Return values | Description |
---|---|---|
unsetEncryption(String token, String nodeId) |
void |
Marks a document as normal binary data in the repository. |
The parameter nodeId should be a document node. This method does not perform any kind of encryption; it simply marks in the database that a document is unencrypted. |
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.unsetEncryption(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338");
} catch (Exception e) {
e.printStackTrace();
}
}
}
setSigned
Description:
Method | Return values | Description |
---|---|---|
setSigned(String token, String nodeId, boolean signed) |
void |
Marks a document as signed or unsigned binary data 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:
Method | Return values | Description |
---|---|---|
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();
}
}
}