OKMProperty
Basics
On most methods you'll see 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 categories folder UUID node.
Example of nodeId:
- Using UUID -> "5cbc35fc-23c0-48f5-a7bc-3cfa1e7be25f";
Also on all methods you'll see parameter named "token". Because the Cron Task are executed in background without authentication, the methods used in this scenario might use the token parameter. From default application execution context you must use "null" value what indicates to the application must use the "user session".
On special cases you might be "promoted as 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 |
Set 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 |
Add a keyword in a node. |
The keyword should be a single word without spaces, formats allowed:
We also we suggest you to add keyword 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 an en cripted binary data in the repository. |
The parameter nodeId should be a document node. The parameter cipherName saves information about the encription mechanism. This method does not perform any kind of encryption, simply mark 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 is a normal binary data into repository. |
The parameter nodeId should be a document node. This method does not perform any kind of encryption, simply mark into the database that a document has been uncrypted. |
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 into the repository. |
The parameter nodeId should be a document node. This method does not perform any kind of digital signature process, simply mark into 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 if the document is signed or not. |
The parameter nodeId should be a document 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);
System.out.println("Is the document signed: " + okmProperty.isSigned(null, "6330d2a0-529f-4c14-baa1-ce6a92004e01"));
} catch (Exception e) {
e.printStackTrace();
}
}
}