OKMNode
Basics
Section titled “Basics”In almost all methods you’ll see a parameter named “nodeId”. The value of this parameter can be a valid node UUID.
About the parameter named “fldId”, the value of this parameter can be a valid folder UUID or a record node.
About the parameter named “dstId”, the value of this parameter can be a valid folder UUID or a record node.
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 that the application must use the “user session”.
Methods
Section titled “Methods”getNodeByUuid
Section titled “getNodeByUuid”Description:
| Method | Return values | Description |
|---|---|---|
| getNodeByUuid(String token, String uuid) | Node | Get a node by UUID. |
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.bean.Node;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); Node node = okmNode.getNodeByUuid(null, "78f9c377-e557-48c7-804e-35c0ca284739"); System.out.println(node); } catch (Exception e) { e.printStackTrace(); } }}getVersionHistory
Section titled “getVersionHistory”Description:
| Method | Return values | Description |
|---|---|---|
| getVersionHistory(String token, String nodeId) | List |
Returns the version history list of a node. |
Example:
package com.openkm;
import java.util.List;
import com.openkm.api.OKMNode;import com.openkm.bean.Version;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); List<Version> versions = okmNode.getVersionHistory(null, "78f9c377-e557-48c7-804e-35c0ca284739"); for (Version version : versions) { System.out.println(version); } } catch (Exception e) { e.printStackTrace(); } }}restoreVersion
Section titled “restoreVersion”Description:
| Method | Return values | Description |
|---|---|---|
| restoreVersion(String token, String nodeId, String versionId) | void | Restore the version of a node. |
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); okmNode.restoreVersion(null, "78f9c377-e557-48c7-804e-35c0ca284739", "1.2"); } catch (Exception e) { e.printStackTrace(); } }}renameVersion
Section titled “renameVersion”Description:
| Method | Return values | Description |
|---|---|---|
| renameVersion(String token, String nodeId, String versionId, String newName) | void | Rename the version of a node. |
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); okmNode.renameVersion(null, "78f9c377-e557-48c7-804e-35c0ca284739", "1.2", "newName"); } catch (Exception e) { e.printStackTrace(); } }}deleteVersion
Section titled “deleteVersion”Description:
| Method | Return values | Description |
|---|---|---|
| deleteVersion(String token, String nodeId, String versionId) | void | Delete a specific version of a node. |
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); okmNode.deleteVersion(null, "78f9c377-e557-48c7-804e-35c0ca284739", "1.2"); } catch (Exception e) { e.printStackTrace(); } }}purgeVersionHistory
Section titled “purgeVersionHistory”Description:
| Method | Return values | Description |
|---|---|---|
| purgeVersionHistory(String token, String nodeId) | void | Purge the version history of a node. |
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); okmNode.purgeVersionHistory(null, "3767deb4-21e7-4272-82be-fece5384fbab"); } catch (Exception e) { e.printStackTrace(); } }}compactVersion
Section titled “compactVersion”Description:
| Method | Return values | Description |
|---|---|---|
| compactVersion(String token, String nodeId, String versionId) | Version | Compacts the indicated version of a node with its immediate previous one into a single history entry. This only works when, between the indicated version and its predecessor, one of the two is a content operation (document/record creation, or a document check-in) and the other is a property group operation (a group added or its properties changed), in either order. The indicated version’s row survives, keeping the combined content and properties, and the predecessor version is removed from the history. |
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.bean.Version;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); Version version = okmNode.compactVersion(null, "78f9c377-e557-48c7-804e-35c0ca284739", "1.2"); System.out.println(version); } catch (Exception e) { e.printStackTrace(); } }}mayBePromotedAsRecord
Section titled “mayBePromotedAsRecord”Description:
| Method | Return values | Description |
|---|---|---|
| mayBePromotedAsRecord(String token, String nodeId, boolean fullEvaluation) | PromoteAsRecordEvaluation | Returns the result of the evaluation to promote a node to the “record” status. When the node cannot be promoted to the “record” status, the result of the evaluation contains information about the reason it cannot be promoted. |
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.plugin.fileplan.record.bean.PromoteAsRecordEvaluation;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); PromoteAsRecordEvaluation pre = okmNode.mayBePromotedAsRecord(null, "3767deb4-21e7-4272-82be-fece5384fbab", false); System.out.println(pre); } catch (Exception e) { e.printStackTrace(); } }}promoteAsRecord
Section titled “promoteAsRecord”Description:
| Method | Return values | Description |
|---|---|---|
| promoteAsRecord(String token, String nodeId) | void | Promote the node to the “record” status. |
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); okmNode.promoteAsRecord(null, "3767deb4-21e7-4272-82be-fece5384fbab"); } catch (Exception e) { e.printStackTrace(); } }}degradeRecord
Section titled “degradeRecord”Description:
| Method | Return values | Description |
|---|---|---|
| degradeRecord(String token, String nodeId) | void | Degrade a node with “record” status. |
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); okmNode.degradeRecord(null, "3767deb4-21e7-4272-82be-fece5384fbab"); } catch (Exception e) { e.printStackTrace(); } }}isElectronicRecordPath
Section titled “isElectronicRecordPath”Description:
| Method | Return values | Description |
|---|---|---|
| isElectronicRecordPath(String token, String nodeId) | boolean | Returns true when the node is in an electronic record. |
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); System.out.println(okmNode.isElectronicRecordPath(null, "3767deb4-21e7-4272-82be-fece5384fbab")); } catch (Exception e) { e.printStackTrace(); } }}getElectronicRecordInPath
Section titled “getElectronicRecordInPath”Description:
| Method | Return values | Description |
|---|---|---|
| getElectronicRecordInPath(String token, String nodeId) | Record | Get the electronic record in the node’s path. |
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.bean.Record;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); Record record = okmNode.getElectronicRecordInPath(null, "3767deb4-21e7-4272-82be-fece5384fbab"); System.out.println(record); } catch (Exception e) { e.printStackTrace(); } }}getChildrenPaginated
Section titled “getChildrenPaginated”Description:
| Method | Return values | Description |
|---|---|---|
| getChildrenPaginated(String token, String nodeId, int offset, int limit, String filter, String orderByField, boolean orderAsc, List<Class<? extends NodeBase>> filteredByNodeTypeList, String pluginName) | PageInfo | Get child nodes, paginated. |
Example:
package com.openkm;
import java.util.ArrayList;import java.util.List;
import com.openkm.api.OKMNode;import com.openkm.bean.PageInfo;import com.openkm.db.bean.NodeBase;import com.openkm.db.bean.NodeDocument;import com.openkm.db.bean.NodeFolder;import com.openkm.db.bean.NodeMail;import com.openkm.db.bean.NodeRecord;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); List<Class<? extends NodeBase>> filteredByNodeTypeList = new ArrayList<>(); filteredByNodeTypeList.add(NodeDocument.class); filteredByNodeTypeList.add(NodeFolder.class); filteredByNodeTypeList.add(NodeMail.class); filteredByNodeTypeList.add(NodeRecord.class);
// nodeId Folder and Record UUID or Path String nodeId = "39479efe-de5e-468e-91a7-24d2aa3f8837"; String orderByField = "created"; boolean orderAsc = true; PageInfo pageInfo = okmNode.getChildrenPaginated(null, nodeId, 0, 10, "", orderByField, orderAsc, filteredByNodeTypeList, null); System.out.println("Filtered Elements: " + pageInfo.getFilteredElements()); System.out.println("Total Elements: " + pageInfo.getTotalElements()); for (Object object : pageInfo.getObjects()) { NodeBase nodeBase = (NodeBase) object; System.out.println(nodeBase.getPath()); } } catch (Exception e) { e.printStackTrace(); } }}getChildrenByCategoryPaginated
Section titled “getChildrenByCategoryPaginated”Description:
| Method | Return values | Description |
|---|---|---|
| getChildrenByCategoryPaginated(String token, String nodeId, int offset, int limit, String filter, String orderByField, boolean orderAsc, List<Class<? extends NodeBase>> filteredByNodeTypeList, String pluginName) | PageInfo | Get child nodes by category, paginated. |
Example:
package com.openkm;
import java.util.ArrayList;import java.util.List;
import com.openkm.api.OKMNode;import com.openkm.bean.PageInfo;import com.openkm.db.bean.NodeBase;import com.openkm.db.bean.NodeDocument;import com.openkm.db.bean.NodeFolder;import com.openkm.db.bean.NodeMail;import com.openkm.db.bean.NodeRecord;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); List<Class<? extends NodeBase>> filteredByNodeTypeList = new ArrayList<>(); filteredByNodeTypeList.add(NodeDocument.class); filteredByNodeTypeList.add(NodeFolder.class); filteredByNodeTypeList.add(NodeMail.class); filteredByNodeTypeList.add(NodeRecord.class);
// nodeId Folder and Record UUID or Path String nodeId = "39479efe-de5e-468e-91a7-24d2aa3f8837"; String orderByField = "created"; boolean orderAsc = true; PageInfo pageInfo = okmNode.getChildrenByCategoryPaginated(null, nodeId, 0, 10, "", orderByField, orderAsc, filteredByNodeTypeList, null); System.out.println("Filtered Elements: " + pageInfo.getFilteredElements()); System.out.println("Total Elements: " + pageInfo.getTotalElements()); for (Object object : pageInfo.getObjects()) { NodeBase nodeBase = (NodeBase) object; System.out.println(nodeBase.getPath()); } } catch (Exception e) { e.printStackTrace(); } }}getBreadcrumb
Section titled “getBreadcrumb”Description:
| Method | Return values | Description |
|---|---|---|
| getBreadcrumb(String token, String fldId) | List |
Get the breadcrumb. |
Example:
package com.openkm;
import java.util.List;
import com.openkm.api.OKMNode;import com.openkm.bean.BreadCrumbItem;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); List<BreadCrumbItem> list = okmNode.getBreadcrumb(null, "39479efe-de5e-468e-91a7-24d2aa3f8837"); for (BreadCrumbItem item : list) { System.out.println(item.getPath()); } } catch (Exception e) { e.printStackTrace(); } }}subscribe
Section titled “subscribe”Description:
| Method | Return values | Description |
|---|---|---|
| subscribe(String token, String nodeId) | void | Adds a subscription to a node. |
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); okmNode.subscribe(null, "39479efe-de5e-468e-91a7-24d2aa3f8837"); } catch (Exception e) { e.printStackTrace(); } }}unsubscribe
Section titled “unsubscribe”Description:
| Method | Return values | Description |
|---|---|---|
| unsubscribe(String token, String nodeId) | void | Deletes a subscription to a node. |
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); okmNode.unsubscribe(null, "39479efe-de5e-468e-91a7-24d2aa3f8837"); } catch (Exception e) { e.printStackTrace(); } }}importZip
Section titled “importZip”Description:
| Method | Return values | Description |
|---|---|---|
| importZip(String token, String fldUuid, InputStream inputStream) | 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.api.OKMNode;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); InputStream is = new FileInputStream("/home/gnujavasergio/okm/import.zip"); okmNode.importZip(null, "212e7c1f-443d-4aac-a12c-0b818ca03419", is); IOUtils.closeQuietly(is); } catch (Exception e) { e.printStackTrace(); } }}Description:
| Method | Return values | Description |
|---|---|---|
| unzip(String token, String uuid, String destinationPath) | void | Unzip a file. |
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); String uuid = "82555dd1-bcc2-4e64-81cb-5f7c2b0d7801"; // zip File String destinationPath = "/okm:root/test"; // destination path okmNode.unzip(null, uuid, destinationPath); } catch (Exception e) { e.printStackTrace(); } }}exportZip
Section titled “exportZip”Description:
| Method | Return values | Description |
|---|---|---|
| exportZip(List |
ByteArrayInputStream | 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.api.OKMNode;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); List<String> uuids = new ArrayList<>(); uuids.add("/okm:root/test/logo.png"); uuids.add("/okm:root/test/invoice.pdf");
OutputStream fos = new FileOutputStream("/home/openkm/import.zip");
InputStream is = okmNode.exportZip(uuids, true, true, true); IOUtils.copy(is, fos); IOUtils.closeQuietly(is); IOUtils.closeQuietly(fos); } catch (Exception e) { e.printStackTrace(); } }}getNodesFromUuids
Section titled “getNodesFromUuids”Description:
| Method | Return values | Description |
|---|---|---|
| getNodesFromUuids(String token, String[] uuids) | List |
Returns a list of nodes. |
Example:
package com.openkm;
import java.util.List;
import com.openkm.api.OKMNode;import com.openkm.bean.Node;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); String[] uuids = {"0f6463f3-4d36-4091-b518-4fe7c353ee70", "d386cff8-1d4d-472f-9c6d-f21955ec499a"}; List<Node> nodes = okmNode.getNodesFromUuids(null, uuids); for (Node node : nodes) { System.out.println(node); } } catch (Exception e) { e.printStackTrace(); } }}evaluateZipDownload
Section titled “evaluateZipDownload”Description:
| Method | Return values | Description |
|---|---|---|
| evaluateZipDownload(String token, List |
ZipDownloadEvaluationResult | Evaluate whether a ZIP file can be downloaded in real-time or in the background. |
Example:
package com.openkm;
import java.util.ArrayList;import java.util.List;
import com.openkm.api.OKMNode;import com.openkm.bean.ZipDownloadEvaluationResult;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); List<String> uuids = new ArrayList<>(); uuids.add("0f6463f3-4d36-4091-b518-4fe7c353ee70"); uuids.add("d386cff8-1d4d-472f-9c6d-f21955ec499a");
ZipDownloadEvaluationResult result = okmNode.evaluateZipDownload(null, uuids); System.out.println(result); } catch (Exception e) { e.printStackTrace(); } }}restore
Section titled “restore”Description:
| Method | Return values | Description |
|---|---|---|
| restore(String token, String nodeId) | Node | Restore a node from the trash. |
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.bean.Node;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); Node node = okmNode.restore(null, "0f6463f3-4d36-4091-b518-4fe7c353ee70"); System.out.println(node); } catch (Exception e) { e.printStackTrace(); } }}hasNodesLockedByOtherUser
Section titled “hasNodesLockedByOtherUser”Description:
| Method | Return values | Description |
|---|---|---|
| hasNodesLockedByOtherUser(String token, String nodeId) | boolean | Checks if the node and its descendants have been locked by other users. |
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); if (okmNode.hasNodesLockedByOtherUser(null, "0f6463f3-4d36-4091-b518-4fe7c353ee70")) { System.out.println("Is blocked"); } } catch (Exception e) { e.printStackTrace(); } }}Description:
| Method | Return values | Description |
|---|---|---|
| lock(String token, String nodeId) | LockInfo | Locks a node and returns an object with the lock information. |
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.bean.LockInfo;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); LockInfo lockInfo = okmNode.lock(null, "1ec49da9-1746-4875-ae32-9281d7303a62"); System.out.println(lockInfo); } catch (Exception e) { e.printStackTrace(); } }}forceLock
Section titled “forceLock”Description:
| Method | Return values | Description |
|---|---|---|
| forceLock(String token, String nodeId) | LockInfo | Locks a node, overriding any existing lock. Returns the new lock information. |
- This method allows locking any already locked node.
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.bean.LockInfo;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); LockInfo lockInfo = okmNode.forceLock(null, "1ec49da9-1746-4875-ae32-9281d7303a62"); System.out.println(lockInfo); } catch (Exception e) { e.printStackTrace(); } }}unlock
Section titled “unlock”Description:
| Method | Return values | Description |
|---|---|---|
| unlock(String token, String nodeId) | void | Unlocks a locked node. |
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); okmNode.unlock(null, "1ec49da9-1746-4875-ae32-9281d7303a62"); } catch (Exception e) { e.printStackTrace(); } }}forceUnlock
Section titled “forceUnlock”Description:
| Method | Return values | Description |
|---|---|---|
| forceUnlock(String token, String nodeId) | void | Unlocks a locked node. |
- This method allows you to unlock any locked node.
- It is not necessary for the same user who previously executed the checkout lock action to perform this action.
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); okmNode.forceUnlock(null, "1ec49da9-1746-4875-ae32-9281d7303a62"); } catch (Exception e) { e.printStackTrace(); } }}isLocked
Section titled “isLocked”Description:
| Method | Return values | Description |
|---|---|---|
| isLocked(String token, String nodeId) | boolean | Returns a boolean that indicates whether the node is locked. |
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); boolean locked = okmNode.isLocked(null, "1ec49da9-1746-4875-ae32-9281d7303a62"); System.out.println(locked); } catch (Exception e) { e.printStackTrace(); } }}getLockInfo
Section titled “getLockInfo”Description:
| Method | Return values | Description |
|---|---|---|
| getLockInfo(String token, String nodeId) | LockInfo | Returns an object with the lock information. |
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); System.out.println(okmNode.getLockInfo(null, "1ec49da9-1746-4875-ae32-9281d7303a62")); } catch (Exception e) { e.printStackTrace(); } }}setComment
Section titled “setComment”Description:
| Method | Return values | Description |
|---|---|---|
| setComment(String token, String nodeId, String versionName, String comment) | void | Sets the comment for a specific node version. |
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); okmNode.setComment(null, "1ec49da9-1746-4875-ae32-9281d7303a62", "1.14", "Update comment"); } catch (Exception e) { e.printStackTrace(); } }}exists
Section titled “exists”Description:
| Method | Return values | Description |
|---|---|---|
| exists(String token, String parentUuid, String name) | boolean | Returns true if a node with the given name exists as a direct child of the specified parent. |
- The parameter parentUuid must be a valid folder or record UUID. The parameter name is the node name to check.
Example:
package com.openkm;
import com.openkm.api.OKMNode;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMNode okmNode = ContextWrapper.getContext().getBean("okmNode", OKMNode.class); boolean exists = okmNode.exists(null, "39479efe-de5e-468e-91a7-24d2aa3f8837", "document.pdf"); System.out.println(exists); } catch (Exception e) { e.printStackTrace(); } }}