OKMRepository
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
getRootFolder
Description:
Method | Return values | Description |
---|---|---|
getRootFolder(String token) |
Folder |
Returns the object Folder of 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 object Folder of node "/okm:trash/{userId}". |
The returned folder will be the user 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 object Folder of 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 object Folder of 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 object Folder of node "/okm:personal/{userId}". |
The returned folder will be the user 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 object Folder of 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 object Folder of node "/okm:mail/{userId}". |
The returned folder will be the user 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 object Folder of 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 object Folder of 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 object Folder of 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 |
Definitively removes from repository all nodes to "/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 will only be able to be restored from a previously repository backup. The purge action removes the node definitely 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's 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 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 node that indicate if a node exists or not. |
The value of the parameter nodeId 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 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 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 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 |
Copy attributes from a node to other.. |
The values 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 |
Return 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> |
Return the list of changes in some path and 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 |
Return 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();
}
}
}