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".
In special cases you might be "promoted to Administrator" using the "administrator token".
String systemToken = DbSessionManager.getInstance().getSystemToken();
Methods
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
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. For example, if the method is executed by the user "okmAdmin", then the folder returned will be "/okm:trash/okmAdmin". |
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
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
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
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. For example, if the method is executed by the user "okmAdmin", then the folder returned will be "/okm:personal/okmAdmin". |
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
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
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. For example, if the method is executed by the user "okmAdmin", then the folder returned will be "/okm:mail/okmAdmin". |
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
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();
}
}
}
getThesaurusFolder
Description:
Method | Return values | Description |
---|---|---|
getThesaurusFolder(String token) |
Folder |
Returns the Folder object for node "/okm:thesaurus". |
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.getThesaurusFolder(null);
System.out.println(fld);
} catch (Exception e) {
e.printStackTrace();
}
}
}
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
Description:
Method | Return values | Description |
---|---|---|
purgeTrash(String token) |
Folder |
Permanently removes from the repository all nodes in "/okm:trash/{userId}". |
For example, if the method is executed by the user "okmAdmin", then the purged trash will be "/okm:trash/okmAdmin". When a node is purged, it can only be restored from a previously made repository backup. The purge action permanently removes the node from the repository. |
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
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. The most common message is that a new OpenKM version has been released. |
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
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
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
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
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
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
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
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
Description:
Method | Return values | Description |
---|---|---|
getChangeLog(String token, String nodePath, Calendar modifyFrom) |
List<ChangeLogged> |
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
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();
}
}
}