OKMRepository
On all methods you'll see parameter named "token". When accessing application across SOAP the login process returns a token, what is used to identify the user on all the exposed methods. 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;
public class Test {
public static void main(String[] args) {
try {
Folder fld = OKMRepository.getInstance().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;
public class Test {
public static void main(String[] args) {
try {
Folder fld = OKMRepository.getInstance().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;
public class Test {
public static void main(String[] args) {
try {
Folder fld = OKMRepository.getInstance().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;
public class Test {
public static void main(String[] args) {
try {
Folder fld = OKMRepository.getInstance().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;
public class Test {
public static void main(String[] args) {
try {
Folder fld = OKMRepository.getInstance().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;
public class Test {
public static void main(String[] args) {
try {
Folder fld = OKMRepository.getInstance().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;
public class Test {
public static void main(String[] args) {
try {
Folder fld = OKMRepository.getInstance().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;
public class Test {
public static void main(String[] args) {
try {
Folder fld = OKMRepository.getInstance().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;
public class Test {
public static void main(String[] args) {
try {
Folder fld = OKMRepository.getInstance().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;
public class Test {
public static void main(String[] args) {
try {
Folder fld = OKMRepository.getInstance().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.bean.Folder;
public class Test {
public static void main(String[] args) {
try {
OKMRepository.getInstance().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;
public class Test {
public static void main(String[] args) {
try {
String msg = OKMRepository.getInstance().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;
public class Test {
public static void main(String[] args) {
try {
String uuid = OKMRepository.getInstance().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 or path. |
Example:
package com.openkm;
import com.openkm.api.OKMRepository;
public class Test {
public static void main(String[] args) {
try {
boolean found = OKMRepository.getInstance().hasNode(null,"/okm:root/test");
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;
public class Test {
public static void main(String[] args) {
try {
String path = OKMRepository.getInstance().getNodePath(null, "064ff51a-b815-4f48-a096-b4946876784f");
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;
public class Test {
public static void main(String[] args) {
try {
String uuid = OKMRepository.getInstance().getNodeUuid(null, "/okm:root/tmp");
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;
public class Test {
public static void main(String[] args) {
try {
AppVersion appVersion = OKMRepository.getInstance().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 or path.
|
Example:
package com.openkm;
import com.openkm.api.OKMRepository;
import com.openkm.bean.ExtendedAttributes;
public class Test {
public static void main(String[] args) {
try {
ExtendedAttributes extAttr = new ExtendedAttributes();
extAttr.setKeywords(true);
extAttr.setCategories(true);
extAttr.setNotes(true);
extAttr.setPropertyGroups(true);
extAttr.setWiki(true);
OKMRepository.getInstance().copyAttributes(null, "/okm:root/invoice.pdf", "/okm:root/cloned_invoice.pdf", extAttr);
} catch (Exception e) {
e.printStackTrace();
}
}
}
registerPropertyGroups
Description:
Method | Return values | Description |
---|---|---|
registerPropertyGroups(String pgDefFile) |
void |
Apply the the XML groups definition into OpenKM. |
The method only can be executed by super user granted ( ROLE_ADMIN member user). Take in mind chaging metadata is done in two steps, first modifiying $TOMCAT_HOME/PropertyGroups.xml file, take a look at registerDefinition in OKMPropertyGroup class for it. Then executing registerPropertyGroups to applying the changes.
|
Example:
package com.openkm;
import com.openkm.core.Config;
import com.openkm.api.OKMRepository;
public class Test {
public static void main(String[] args) {
try {
OKMRepository.getInstance().registerPropertyGroups(null, Config.PROPERTY_GROUPS_XML);
} catch (Exception e) {
e.printStackTrace();
}
}
}