OKMRepository
On all methods you’ll see a parameter named “token”. Because the Cron Task is 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”.
Methods
Section titled “Methods”getRootFolder
Section titled “getRootFolder”Description:
| Method | Return values | Description |
|---|---|---|
| getRootFolder(String token) | Folder | Returns the Folder object for node “/okm:root”. |
Example:
package com.openkm;
import com.openkm.api.OKMRepository;import com.openkm.bean.Folder;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMRepository okmRepository = ContextWrapper.getContext().getBean(OKMRepository.class); Folder fld = okmRepository.getRootFolder(null); System.out.println(fld); } catch (Exception e) { e.printStackTrace(); } }}getTrashFolder
Section titled “getTrashFolder”Description:
| Method | Return values | Description |
|---|---|---|
| getTrashFolder(String token) | Folder | Returns the Folder object for node “/okm:trash/{userId}”. |
- The returned folder will be the user’s trash folder.
Example:
package com.openkm;
import com.openkm.api.OKMRepository;import com.openkm.bean.Folder;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMRepository okmRepository = ContextWrapper.getContext().getBean(OKMRepository.class); Folder fld = okmRepository.getTrashFolder(null); System.out.println(fld); } catch (Exception e) { e.printStackTrace(); } }}getTrashFolderBase
Section titled “getTrashFolderBase”Description:
| Method | Return values | Description |
|---|---|---|
| getTrashFolderBase(String token) | Folder | Returns the Folder object for node “/okm:trash”. |
Example:
package com.openkm;
import com.openkm.api.OKMRepository;import com.openkm.bean.Folder;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMRepository okmRepository = ContextWrapper.getContext().getBean(OKMRepository.class); Folder fld = okmRepository.getTrashFolderBase(null); System.out.println(fld); } catch (Exception e) { e.printStackTrace(); } }}getTemplatesFolder
Section titled “getTemplatesFolder”Description:
| Method | Return values | Description |
|---|---|---|
| getTemplatesFolder(String token) | Folder | Returns the Folder object for node “/okm:templates”. |
Example:
package com.openkm;
import com.openkm.api.OKMRepository;import com.openkm.bean.Folder;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMRepository okmRepository = ContextWrapper.getContext().getBean(OKMRepository.class); Folder fld = okmRepository.getTemplatesFolder(null); System.out.println(fld); } catch (Exception e) { e.printStackTrace(); } }}getPersonalFolder
Section titled “getPersonalFolder”Description:
| Method | Return values | Description |
|---|---|---|
| getPersonalFolder(String token) | Folder | Returns the Folder object for node “/okm:personal/{userId}”. |
- The returned folder will be the user’s personal folder.
Example:
package com.openkm;
import com.openkm.api.OKMRepository;import com.openkm.bean.Folder;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMRepository okmRepository = ContextWrapper.getContext().getBean(OKMRepository.class); Folder fld = okmRepository.getPersonalFolder(null); System.out.println(fld); } catch (Exception e) { e.printStackTrace(); } }}getPersonalFolderBase
Section titled “getPersonalFolderBase”Description:
| Method | Return values | Description |
|---|---|---|
| getPersonalFolderBase(String token) | Folder | Returns the Folder object for node “/okm:personal”. |
Example:
package com.openkm;
import com.openkm.api.OKMRepository;import com.openkm.bean.Folder;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMRepository okmRepository = ContextWrapper.getContext().getBean(OKMRepository.class); Folder fld = okmRepository.getPersonalFolderBase(null); System.out.println(fld); } catch (Exception e) { e.printStackTrace(); } }}getMailFolder
Section titled “getMailFolder”Description:
| Method | Return values | Description |
|---|---|---|
| getMailFolder(String token) | Folder | Returns the Folder object for node “/okm:mail/{userId}”. |
- The returned folder will be the user’s mail folder.
Example:
package com.openkm;
import com.openkm.api.OKMRepository;import com.openkm.bean.Folder;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMRepository okmRepository = ContextWrapper.getContext().getBean(OKMRepository.class); Folder fld = okmRepository.getMailFolder(null); System.out.println(fld); } catch (Exception e) { e.printStackTrace(); } }}getMailFolderBase
Section titled “getMailFolderBase”Description:
| Method | Return values | Description |
|---|---|---|
| getMailFolderBase(String token) | Folder | Returns the Folder object for node “/okm:mail”. |
Example:
package com.openkm;
import com.openkm.api.OKMRepository;import com.openkm.bean.Folder;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMRepository okmRepository = ContextWrapper.getContext().getBean(OKMRepository.class); Folder fld = okmRepository.getMailFolderBase(null); System.out.println(fld); } catch (Exception e) { e.printStackTrace(); } }}getCategoriesFolder
Section titled “getCategoriesFolder”Description:
| Method | Return values | Description |
|---|---|---|
| getCategoriesFolder(String token) | Folder | Returns the Folder object for node “/okm:categories”. |
Example:
package com.openkm;
import com.openkm.api.OKMRepository;import com.openkm.bean.Folder;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMRepository okmRepository = ContextWrapper.getContext().getBean(OKMRepository.class); Folder fld = okmRepository.getCategoriesFolder(null); System.out.println(fld); } catch (Exception e) { e.printStackTrace(); } }}purgeTrash
Section titled “purgeTrash”Description:
| Method | Return values | Description |
|---|---|---|
| purgeTrash(String token) | void | Permanently removes from the repository all nodes in “/okm:trash/{userId}”. |
Example:
package com.openkm;
import com.openkm.api.OKMRepository;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMRepository okmRepository = ContextWrapper.getContext().getBean(OKMRepository.class); okmRepository.purgeTrash(null); } catch (Exception e) { e.printStackTrace(); } }}getUpdateMessage
Section titled “getUpdateMessage”Description:
| Method | Return values | Description |
|---|---|---|
| getUpdateMessage(String token) | String | Retrieves a message when there is a new OpenKM release. |
- There is an official OpenKM update message service available, which is based on your local OpenKM version.
Example:
package com.openkm;
import com.openkm.api.OKMRepository;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMRepository okmRepository = ContextWrapper.getContext().getBean(OKMRepository.class); String msg = okmRepository.getUpdateMessage(null); System.out.println(msg); } catch (Exception e) { e.printStackTrace(); } }}getRepositoryUuid
Section titled “getRepositoryUuid”Description:
| Method | Return values | Description |
|---|---|---|
| getRepositoryUuid(String token) | String | Retrieves the installation’s unique identifier. |
Example:
package com.openkm;
import com.openkm.api.OKMRepository;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMRepository okmRepository = ContextWrapper.getContext().getBean(OKMRepository.class); String uuid = okmRepository.getRepositoryUuid(null); System.out.println(uuid); } catch (Exception e) { e.printStackTrace(); } }}hasNode
Section titled “hasNode”Description:
| Method | Return values | Description |
|---|---|---|
| hasNode(String token, String nodeId) | boolean | Returns a value that indicates whether a node exists. |
- The value of the nodeId parameter can be a valid UUID.
Example:
package com.openkm;
import com.openkm.api.OKMRepository;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMRepository okmRepository = ContextWrapper.getContext().getBean(OKMRepository.class); boolean found = okmRepository.hasNode(null, "b67fe3ae-bcca-4947-b8ea-0cc7aedd4474"); System.out.println(found); } catch (Exception e) { e.printStackTrace(); } }}getNodePath
Section titled “getNodePath”Description:
| Method | Return values | Description |
|---|---|---|
| getNodePath(String token, String uuid) | String | Converts a node UUID to a path. |
Example:
package com.openkm;
import com.openkm.api.OKMRepository;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMRepository okmRepository = ContextWrapper.getContext().getBean(OKMRepository.class); String path = okmRepository.getNodePath(null, "b67fe3ae-bcca-4947-b8ea-0cc7aedd4474"); System.out.println(path); } catch (Exception e) { e.printStackTrace(); } }}getNodeUuid
Section titled “getNodeUuid”Description:
| Method | Return values | Description |
|---|---|---|
| getNodeUuid(String token, String path) | String | Converts a node path to a UUID. |
Example:
package com.openkm;
import com.openkm.api.OKMRepository;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMRepository okmRepository = ContextWrapper.getContext().getBean(OKMRepository.class); String uuid = okmRepository.getNodeUuid(null, "/okm:root/api"); System.out.println(uuid); } catch (Exception e) { e.printStackTrace(); } }}getAppVersion
Section titled “getAppVersion”Description:
| Method | Return values | Description |
|---|---|---|
| getAppVersion(String token) | AppVersion | Returns information about the OpenKM version. |
Example:
package com.openkm;import com.openkm.api.OKMRepository;import com.openkm.bean.AppVersion;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMRepository okmRepository = ContextWrapper.getContext().getBean(OKMRepository.class); AppVersion appVersion = okmRepository.getAppVersion(null); System.out.println(appVersion); } catch (Exception e) { e.printStackTrace(); } }}copyAttributes
Section titled “copyAttributes”Description:
| Method | Return values | Description |
|---|---|---|
| copyAttributes(String token, String srcId, String dstId, ExtendedAttributes extAttr) | void | Copies attributes from one node to another. |
- The value of the dstId parameter should be a node UUID.
Example:
package com.openkm;
import com.openkm.api.OKMRepository;import com.openkm.bean.ExtendedAttributes;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMRepository okmRepository = ContextWrapper.getContext().getBean(OKMRepository.class); ExtendedAttributes extAttr = new ExtendedAttributes(); extAttr.setKeywords(true); extAttr.setCategories(true); extAttr.setNotes(true); extAttr.setPropertyGroups(true); extAttr.setWiki(true); okmRepository.copyAttributes(null, "d168924d-e801-426d-a222-00124a1461bd", "9f64248c-e049-4706-b89e-6d725842c7f7", extAttr); } catch (Exception e) { e.printStackTrace(); } }}getMetadataFolder
Section titled “getMetadataFolder”Description:
| Method | Return values | Description |
|---|---|---|
| getMetadataFolder(String token) | Folder | Returns the metadata folder. |
Example:
package com.openkm;
import com.openkm.api.OKMRepository;import com.openkm.bean.Folder;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMRepository okmRepository = ContextWrapper.getContext().getBean(OKMRepository.class);
Folder folder = okmRepository.getMetadataFolder(null); System.out.println(folder); } catch (Exception e) { e.printStackTrace(); } }}getChangeLog
Section titled “getChangeLog”Description:
| Method | Return values | Description |
|---|---|---|
| getChangeLog(String token, String nodePath, Calendar modifyFrom) | List |
Returns the list of changes in a path and its subfolders. |
Example:
package com.openkm;
import java.util.Calendar;
import com.openkm.api.OKMRepository;import com.openkm.bean.ChangeLogged;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMRepository okmRepository = ContextWrapper.getContext().getBean(OKMRepository.class);
Calendar now = Calendar.getInstance(); for (ChangeLogged cl : okmRepository.getChangeLog(null, "/okm:root/synchronized", now)) { System.out.println(cl); } } catch (Exception e) { e.printStackTrace(); } }}getAppLicense
Section titled “getAppLicense”Description:
| Method | Return values | Description |
|---|---|---|
| getAppLicense(String token) | LicenseInfo | Returns license information. |
Example:
package com.openkm;
import com.openkm.api.OKMRepository;import com.openkm.util.ContextWrapper;import com.openkm.util.Update.LicenseInfo;
public class Test {
public static void main(String[] args) { try { OKMRepository okmRepository = ContextWrapper.getContext().getBean(OKMRepository.class);
LicenseInfo licenseInfo = okmRepository.getAppLicense(null); System.out.println(licenseInfo); } catch (Exception e) { e.printStackTrace(); } }}