Skip to content
Other versions

Loading…

OKMDocument

On almost methods you’ll see parameter named “docId”. The value of this parameter can be some valid document UUID or path node.

About the parameter named “fldId”, the value of this parameter can be some valid folder UUID or path or record node.

About the parameter named “dstId”, the value of this parameter can be some valid folder UUID or path or record node.

Also 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”.

Description:

Method Return values Description
create(String token, Document doc, InputStream is) Document Create a new document.
  • The parameter doc must be initialized with the OpenKM path value into the repository. Optionally you can also set keywords and title values.

Example:

package com.openkm;
import java.io.FileInputStream;
import java.io.InputStream;
import org.apache.commons.io.IOUtils;
import com.openkm.api.OKMDocument;
import com.openkm.bean.Document;
public class Test {
public static void main(String[] args) {
InputStream is = null;
try {
is = new FileInputStream("/home/user/sample.pdf");
Document doc = new Document();
doc.setPath("/okm:root/sample.pdf");
// Optional
doc.setTitle("sample document");
doc.getKeywords().add("key1");
doc.getKeywords().add("key2");
// Create document
doc = OKMDocument.getInstance().create(null, doc, is);
System.out.println(doc);
} catch (Exception e) {
e.printStackTrace();
} finally {
IOUtils.closeQuietly(is);
}
}
}

Description:

Method Return values Description
createSimple(String token, String docPath, InputStream is) Document Create a new document.

Example:

package com.openkm;
import java.io.FileInputStream;
import java.io.InputStream;
import org.apache.commons.io.IOUtils;
import com.openkm.api.OKMDocument;
import com.openkm.bean.Document;
public class Test {
public static void main(String[] args) {
InputStream is = null;
try {
is = new FileInputStream("/home/user/sample.pdf");
String docPath = "/okm:root/sample.pdf";
Document doc = OKMDocument.getInstance().createSimple(null, docPath, is);
System.out.println(doc);
} catch (Exception e) {
e.printStackTrace();
} finally {
IOUtils.closeQuietly(is);
}
}
}

Description:

Method Return values Description
delete(String token, String docId) void Delete a document.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
// Delete document by path
OKMDocument.getInstance().delete(null, "/okm:root/sample.pdf");
// Delete document by uuid
OKMDocument.getInstance().delete(null, "adc048d7-3791-4540-ae32-680629f73875");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getProperties(String token, String docId) Document Return a document properties.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
import com.openkm.bean.Document;
public class Test {
public static void main(String[] args) {
try {
Document doc = OKMDocument.getInstance().getProperties(null, "adc048d7-3791-4540-ae32-680629f73875");
System.out.println(doc);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getContent(String token, String docId, boolean checkout) InputStream Return the document content.
  • When paramer checkout is true, the document is marked for edition.

Example:

package com.openkm;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.io.IOUtils;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
InputStream is = null;
OutputStream fos = null;
try {
is = OKMDocument.getInstance().getContent(null, "adc048d7-3791-4540-ae32-680629f73875", false);
File tmp = new File("/home/user/sample.pdf");
fos = new FileOutputStream(tmp);
IOUtils.copy(is, fos);
} catch (Exception e) {
e.printStackTrace();
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(fos);
}
}
}

Description:

Method Return values Description
getContentByVersion(String token, String docId, String versionId) InputStream Return the document content by version.
  • The parameter versionIs is the name of the document version.

Example:

package com.openkm;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import org.apache.commons.io.IOUtils;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
InputStream is = null;
OutputStream fos = null;
try {
is = OKMDocument.getInstance().getContentByVersion(null, "adc048d7-3791-4540-ae32-680629f73875", "1.1");
File tmp = new File("/home/user/sample.pdf");
fos = new FileOutputStream(tmp);
IOUtils.copy(is, fos);
} catch (Exception e) {
e.printStackTrace();
} finally {
IOUtils.closeQuietly(is);
IOUtils.closeQuietly(fos);
}
}
}

Description:

Method Return values Description
getExtractedText(String token, String docId) String Return the extracted text of the document.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
String indexedText = OKMDocument.getInstance().getExtractedText(null, "adc048d7-3791-4540-ae32-680629f73875");
System.out.println(indexedText);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getChilds(String token, String fldId) List Returns a list of all documents which their parent is fldId.
  • The parameter fldId can be a folder or a record node.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
import com.openkm.bean.Document;
public class Test {
public static void main(String[] args) {
try {
for (Document doc : OKMDocument.getInstance().getChilds(null, "/okm:root/import")) {;
System.out.println(doc);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Descripcion:

Method Return values Description
getChildren(String token, String fldId) List Returns a list of all documents which their parent is fldId.
  • The parameter fldId can be a folder or a record node.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
import com.openkm.bean.Document;
public class Test {
public static void main(String[] args) {
try {
for (Document doc : OKMDocument.getInstance().getChildren(null, "/okm:root/import")) {;
System.out.println(doc);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
rename(String token, String docId, String newName) Document Changes the name of a document.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
import com.openkm.bean.Document;
public class Test {
public static void main(String[] args) {
try {
Document doc = OKMDocument.getInstance().rename(null, "/okm:root/samples.pdf","samples_renamed.pdf");
System.out.println(doc);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
setProperties(String token, Document doc) void Changes some document properties.
  • Variables allowed to be changed:

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
import com.openkm.bean.Document;
public class Test {
public static void main(String[] args) {
try {
Document doc = OKMDocument.getInstance().getProperties(null, "/okm:root/samples.pdf");
doc.getKeywords().add("key1");
doc.setDescription("some description");
OKMDocument.getInstance().setProperties(null, doc);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
setLanguage(String token, String docId, String lang) void Sets the document language.
  • The parameter lang must be ISO 691-1 compliant.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
OKMDocument.getInstance().setLanguage(null, "/okm:root/samples.pdf","en");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
setTitle(String token, String docId, String title) void Sets the document title.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
OKMDocument.getInstance().setTitle(null, "/okm:root/samples.pdf","Document title");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
checkout(String token, String docId) void Marks the document for edition.
  • Only one user can modify a document at a time.
  • Before starting edition you must do a checkout action that locks the edition process for other users and allows edition only to the user who has executed the action.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
OKMDocument.getInstance().checkout(null, "/okm:root/samples.pdf");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
cancelCheckout(String token, String docId) void Cancels a document edition.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
OKMDocument.getInstance().cancelCheckout(null, "/okm:root/samples.pdf");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
forceCancelCheckout(String token, String docId) void Cancels a document edition.
  • This method allows to cancel edition on any document.
  • It is not mandatory to execute this action by the same user who previously executed the checkout action.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
OKMDocument.getInstance().forceCancelCheckout(null, "/okm:root/samples.pdf");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
isCheckedOut(String token, String docId) void Returns a boolean that indicates if the document is on edition or not.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
System.out.println(OKMDocument.getInstance().isCheckedOut(null, "/okm:root/samples.pdf"));
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
checkin(String token, String docId, InputStream is, String comment) Version Updates a document with a new version and returns an object with new Version values.

Example:

package com.openkm;
import java.io.FileInputStream;
import java.io.InputStream;
import org.apache.poi.util.IOUtils;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
InputStream is = null;
try {
is = new FileInputStream("/home/user/sample.pdf");
OKMDocument.getInstance().checkin(null, "/okm:root/samples.pdf", is, "optional comment");
} catch (Exception e) {
e.printStackTrace();
} finally {
IOUtils.closeQuietly(is);
}
}
}

Description:

Method Return values Description
checkin(String token, String docId, InputStream is, String comment, int increment) Version Updates a document with a new version and returns an object with new Version values.
  • The increment value depends on VersionNumeration implementation. Common values are:

Example:

package com.openkm;
import java.io.FileInputStream;
import java.io.InputStream;
import org.apache.poi.util.IOUtils;
import com.openkm.api.OKMDocument;
import com.openkm.vernum.VersionNumerationAdapter;
public class Test {
public static void main(String[] args) {
InputStream is = null;
try {
is = new FileInputStream("/home/user/sample.pdf");
OKMDocument.getInstance().checkin(null, "/okm:root/samples.pdf", is, "optional comment", VersionNumerationAdapter.INCREASE_MINOR);
} catch (Exception e) {
e.printStackTrace();
} finally {
IOUtils.closeQuietly(is);
}
}
}

Description:

Method Return values Description
isCheckedOut(String token, String docId) void Returns a boolean that indicates if the document is on edition or not.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
System.out.println(OKMDocument.getInstance().isCheckedOut(null, "/okm:root/samples.pdf"));
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getVersionHistory(String token, String docId List Returns a list of all document versions.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
import com.openkm.bean.Version;
public class Test {
public static void main(String[] args) {
try {
for (Version ver :OKMDocument.getInstance().getVersionHistory(null, "/okm:root/samples.pdf")) {
System.out.println(ver);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
lock(String token, String docId LockInfo Locks a document and returns an object with the Lock information.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
import com.openkm.bean.LockInfo;
public class Test {
public static void main(String[] args) {
try {
LockInfo lockInfo = OKMDocument.getInstance().lock(null, "/okm:root/samples.pdf"));
System.out.println(lockInfo);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
unlock(String token, String docId LockInfo Unlocks a locked document.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
OKMDocument.getInstance().unlock(null, "/okm:root/samples.pdf"));
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
forceUnlock(String token, String docId LockInfo Unlocks a locked document.
  • This method allows to unlock any locked document.
  • It is not mandatory execute this action by the same user who previously executed the checkout lock action.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
OKMDocument.getInstance().forceUnlock(null, "/okm:root/samples.pdf"));
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
isLocked(String token, String docId) void Returns a boolean that indicates if the document is locked or not.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
System.out.println(OKMDocument.getInstance().isLocked(null, "/okm:root/samples.pdf"));
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getLockInfo(String token, String docId) LockInfo Returns an object with the Lock information.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
import com.openkm.bean.LockInfo;
public class Test {
public static void main(String[] args) {
try {
LockInfo lockInfo = OKMDocument.getInstance().getLockInfo(null, "/okm:root/samples.pdf"));
System.out.println(lockInfo);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
purge(String token, String docId) void The document is definitely removed from repository.
  • Usually you will purge documents into /okm:trash/userId - the personal trash user locations - but is possible to directly purge any document from the whole repository.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
OKMDocument.getInstance().purge(null, "/okm:root/samples.pdf"));
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
move(String token, String docId, String dstId) void Move document into some folder or record.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
OKMDocument.getInstance().move(null, "/okm:root/samples.pdf", "/okm/root/temp"));
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
copy(String token, String docId, String dstId) void Copy a document into some folder or record.
  • The values of the dstId parameter should be a folder or record UUID or path.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
OKMDocument.getInstance().copy(null, "/okm:root/samples.pdf", "/okm/root/temp"));
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
copy(String token, String docId, String dstId, String newName) void Copy a document into some folder or record.
  • The values of the dstId parameter should be a folder or record UUID or path.
  • When the parameter newName value is null,the  document will preservate the same name.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
OKMDocument.getInstance().copy(null, "/okm:root/samples.pdf", "/okm/root/temp", "samples_renamed.pdf"));
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
extendedCopy(String token, String docId, String dstId, String docName, ExtendedAttributes extAttr) void Copies a document with associated data into some folder or record.
  • The values of the dstId parameter should be a folder or a record UUID or path.
  • When the parameter docName value is null, the document will preserve the same name.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
import com.openkm.bean.ExtendedAttributes;
public class Test {
public static void main(String[] args) {
try {
ExtendedAttributes extAttr = new ExtendedAttributes();
// copy keywords
extAttr.setKeywords(true);
OKMDocument.getInstance().extendedCopy(null, "/okm:root/samples.pdf", "/okm:root/temp", "samples_renamed.pdf", extAttr);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
restoreVersion(String token, String docId, String versionId) void Restores previously document version to actual version.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
OKMDocument.getInstance().restoreVersion(null, "/okm:root/samples.pdf", "1.2");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
purgeVersionHistory(String token, String docId) void Purges all the previous document versions except the actual version.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
OKMDocument.getInstance().purgeVersionHistory(null, "/okm:root/samples.pdf");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getVersionHistorySize(String token, String docId) long Returns the sum in bytes of all documents into documents history.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
import com.openkm.util.FormatUtil;
public class Test {
public static void main(String[] args) {
try {
System.out.println(FormatUtil.formatSize(OKMDocument.getInstance().getVersionHistorySize(null, "/okm:root/samples.pdf")));
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
isValid(String token, String docId) boolean Returns a boolean that indicates if the node is a document or not.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
boolean valid = OKMDocument.getInstance().isValid(null, "/okm:root/samples.pdf");
System.out.println(valid);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getPath(String token, String uuid) String Converts a document UUID to document path.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
String docPath = OKMDocument.getInstance().getPath(null, "f123a950-0329-4d62-8328-0ff500fd42dbg");
System.out.println(docPath);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getDetectedLanguages(String token) List Return a list of available document languages what OpenKM can identify.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
for (String languages : OKMDocument.getInstance().getDetectedLanguages(null)) {
System.out.println(languages);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
createFromTemplate(String token, String docId, String dstPath, List properties, ExtendedAttributes attribute) Document Creates a new document from template and returns an object Document.
  • The dstPath can be a folder or a record path.
  • The parameter language is optional.
  • When the template uses metadata groups to fill fields into, then these values are mandatory and must be set into properties parameter. 

Example:

package com.openkm;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import com.openkm.api.OKMDocument;
import com.openkm.bean.ExtendedAttributes;
import com.openkm.bean.form.FormElement;
import com.openkm.bean.form.Input;
import com.openkm.bean.form.Option;
import com.openkm.bean.form.Select;
import com.openkm.util.ISO8601;
public class Test {
public static void main(String[] args) {
try {
List<FormElement> formElements = new ArrayList<>();
Input name = new Input();
name.setName("okp:tpl.name");
name.setValue("Some name");
formElements.add(name);
Input birdDate = new Input();
birdDate.setName("okp:tpl.bird_date");
Calendar cal = Calendar.getInstance();
// Value must be converted to String ISO 8601 compliant
birdDate.setValue(ISO8601.formatBasic(cal));
formElements.add(birdDate);
Select language = new Select();
language.setName("okp:tpl.language");
// With selected option is enought
Option option = new Option();
option.setValue("java");
option.setSelected(true);
language.getOptions().add(option);
formElements.add(language);
OKMDocument.getInstance().createFromTemplate(null, "/okm:templates/tpl.pdf", "/okm:root/test", formElements, new ExtendedAttributes());
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
createFromTemplateSimple(String token, String docId, String dstPath, Map<String, String> properties, ExtendedAttributes attributes) Document Creates a new document from template and returns an object Document.
  • The dstPath can be a folder or a record path.
  • The parameter language is optional.
  • When the template uses metadata groups to fill fields into, then these values are mandatory and must be set into properties parameter. 

Example:

package com.openkm;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import com.openkm.api.OKMDocument;
import com.openkm.bean.ExtendedAttributes;
import com.openkm.util.ISO8601;
public class Test {
public static void main(String[] args) {
try {
Map<String, String> properties = new HashMap<>();
properties.put("okp:tpl.name", "Some name");
Calendar cal = Calendar.getInstance();
// Value must be converted to String ISO 8601 compliant
properties.put("okp:tpl.bird_date", ISO8601.formatBasic(cal));
properties.put("okp:tpl.language", "java");
OKMDocument.getInstance().createFromTemplateSimple(null, "/okm:templates/tpl.pdf", "/okm:root/test", properties, new ExtendedAttributes());
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
updateFromTemplate(String token, String docId, String dstId, List properties) void Updates a document previously created from the template and returns an object Document.
  • This method only has sense when the template uses metadata groups to fill fields in.

Example:

package com.openkm;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import com.openkm.api.OKMDocument;
import com.openkm.bean.form.FormElement;
import com.openkm.bean.form.Input;
import com.openkm.bean.form.Option;
import com.openkm.bean.form.Select;
import com.openkm.util.ISO8601;
public class Test {
public static void main(String[] args) {
try {
List<FormElement> formElements = new ArrayList<>();
Input name = new Input();
name.setName("okp:tpl.name");
name.setValue("Some name");
formElements.add(name);
Input birdDate = new Input();
birdDate.setName("okp:tpl.bird_date");
Calendar cal = Calendar.getInstance();
// Value must be converted to String ISO 8601 compliant
birdDate.setValue(ISO8601.formatBasic(cal));
formElements.add(birdDate);
Select language = new Select();
language.setName("okp:tpl.language");
// With selected option is enought
Option option = new Option();
option.setValue("java");
option.setSelected(true);
language.getOptions().add(option);
formElements.add(language);
OKMDocument.getInstance().updateFromTemplate(null, "/okm:templates/tpl.pdf", "/okm:root/test", formElements);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
updateFromTemplateSimple(String token, String docId, String dstId, Map<String, String> properties) void Updates a document previously created from the template and returns an object Document.
  • This method only has sense when the template uses metadata groups to fill fields in.

Example:

package com.openkm;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
import com.openkm.api.OKMDocument;
import com.openkm.util.ISO8601;
public class Test {
public static void main(String[] args) {
try {
Map<String, String> properties = new HashMap<>();
properties.put("okp:tpl.name", "Some name");
Calendar cal = Calendar.getInstance();
// Value must be converted to String ISO 8601 compliant
properties.put("okp:tpl.bird_date", ISO8601.formatBasic(cal));
properties.put("okp:tpl.language", "java");
OKMDocument.getInstance().updateFromTemplateSimple(null, "/okm:templates/tpl.pdf", "/okm:root/test", properties);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
setAnnotations(String token, String docId, String verName, String annotation) void Set document annotations of some document version.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
OKMDocument.getInstance().setAnnotations(null, "/okm:root/samples.pdf", "1.1", "The annotation text.");
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getAnnotations(String token, String docId, String verName) String Return the document annotations of some document version.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
String annotation = OKMDocument.getInstance().getAnnotations(null, "/okm:root/samples.pdf", "1.1");
System.out.println(annotation);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getCheckedOut(String token) List Return the list of all documents checkout in the repository

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
import com.openkm.bean.Document;
public class Test {
public static void main(String[] args) {
try {
for (Document doc : OKMDocument.getInstance().getCheckedOut(null)) {
System.out.println(doc);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
stamp(String token, String docId, int type, long stId) void Stamp a document.
  • The parameter type indicates stamp type:
  • The parameter stId is the unique identifier value of the stamp definition. You can get it from Administration > Stamp view.

Example:

package com.openkm;
import com.openkm.api.OKMDocument;
public class Test {
public static void main(String[] args) {
try {
int type = 0; // indicate text stamp definition
long stId = 12; // unique identifier of the stamp definition
OKMDocument.getInstance().stamp(null, "/okm:root/sample.pdf", type, stId);
} catch (Exception e) {
e.printStackTrace();
}
}
}