Record samples
Basics
Section titled “Basics”Suggested code sample
Section titled “Suggested code sample”First, you must create the webservice object:
OKMWebservices ws = OKMWebservicesFactory.getInstance(host);Then you should log in using the method “login”. You can access the “login” method from the webservice object “ws” as shown below:
ws.login(user, password);At this point you can use all the Record methods in the “record” class as shown below:
ws.record.create("ada67d44-b081-4b23-bdc1-74181cafbc5d", "PKI-100200", "new title", 0)Methods
Section titled “Methods”create
Section titled “create”Description:
| Method | Return values | Description |
|---|---|---|
| create(String uuid, String name, String title, long nodeClass) | Record | Creates a new record and returns a Record object. |
- The parameter uuid should be a valid folder or record UUID.
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.bean.Record;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); Record record = ws.record.create("ada67d44-b081-4b23-bdc1-74181cafbc5d", "PKI-100200", "new title", 0); System.out.println(record); } catch (Exception e) { e.printStackTrace(); } }}createWithPropertyGroup
Section titled “createWithPropertyGroup”Description:
| Method | Return values | Description |
|---|---|---|
| createWithPropertyGroup(String uuid, String name, String title, long nodeClass, String grpName, Map<String, String> properties) | Record | Creates a new record and sets a property group’s properties in the same call. Returns a Record object. |
- The parameter uuid should be a valid folder or record UUID.
- The grpName should be a valid Metadata group name.
- It is not mandatory to set all field values in the properties parameter; only the properties belonging to grpName are applied.
Example:
package com.openkm;
import java.util.HashMap;import java.util.Map;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.bean.Record;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); Map<String, String> properties = new HashMap<>(); properties.put("okp:technology.comment", "comment sample"); properties.put("okp:technology.description", "description sample"); Record record = ws.record.createWithPropertyGroup("ada67d44-b081-4b23-bdc1-74181cafbc5d", "PKI-100200", "new title", 0, "okg:technology", properties); System.out.println(record); } catch (Exception e) { e.printStackTrace(); } }}getProperties
Section titled “getProperties”Description:
| Method | Return values | Description |
|---|---|---|
| getProperties(String uuid) | Record | Returns the record properties. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); System.out.println(ws.record.getProperties("fbe2933e-b141-4557-ab7a-736820ecdb2e")); } catch (Exception e) { e.printStackTrace(); } }}delete
Section titled “delete”Description:
| Method | Return values | Description |
|---|---|---|
| delete(String uuid) | void | Deletes a record. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); ws.record.delete("fbe2933e-b141-4557-ab7a-736820ecdb2e"); } catch (Exception e) { e.printStackTrace(); } }}Description:
| Method | Return values | Description |
|---|---|---|
| purge(String uuid) | void | The record is permanently removed from the repository. |
- Usually you will purge records to /okm:trash/userId - the user’s personal trash location - but it is possible to directly purge any record from the repository.
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); ws.record.purge("fbe2933e-b141-4557-ab7a-736820ecdb2e"); } catch (Exception e) { e.printStackTrace(); } }}rename
Section titled “rename”Description:
| Method | Return values | Description |
|---|---|---|
| rename(String uuid, String newName) | Record | Renames a record. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); ws.record.rename("5489fc37-3eb7-43de-998c-319725ae0ca0", "new_name"); } catch (Exception e) { e.printStackTrace(); } }}Description:
| Method | Return values | Description |
|---|---|---|
| move(String uuid, String dstId) | void | Moves a record to a folder or another record. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); ws.record.move("5489fc37-3eb7-43de-998c-319725ae0ca0", "8599eab7-ae61-4628-8010-1103d6950c63"); } catch (Exception e) { e.printStackTrace(); } }}Description:
| Method | Return values | Description |
|---|---|---|
| copy(String uuid, String dstId, String newName) | void | Copies a record to a folder or another record. |
- The value of the dstId parameter should be a folder or record UUID.
- When the newName parameter value is null, the record will preserve the same name.
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); ws.record.copy("5489fc37-3eb7-43de-998c-319725ae0ca0", "8599eab7-ae61-4628-8010-1103d6950c63", "PKI-100200"); } catch (Exception e) { e.printStackTrace(); } }}isValid
Section titled “isValid”Description:
| Method | Return values | Description |
|---|---|---|
| isValid(String uuid) | Boolean | Returns a boolean that indicates whether the node is a record. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); System.out.println("Is a record:" + ws.record.isValid("5489fc37-3eb7-43de-998c-319725ae0ca0")); } catch (Exception e) { e.printStackTrace(); } }}getChildren
Section titled “getChildren”Description:
| Method | Return values | Description |
|---|---|---|
| getChildren(String uuid) | List |
Returns a list of all records whose parent is uuid. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.bean.Record;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); for (Record rec : ws.record.getChildren("8599eab7-ae61-4628-8010-1103d6950c63")) { System.out.println(rec); } } catch (Exception e) { e.printStackTrace(); } }}setTitle
Section titled “setTitle”Description:
| Method | Return values | Description |
|---|---|---|
| setTitle(String uuid, String title) | void | Sets a record title. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); ws.record.setTitle("5489fc37-3eb7-43de-998c-319725ae0ca0", "some title"); } catch (Exception e) { e.printStackTrace(); } }}getPath
Section titled “getPath”Description:
| Method | Return values | Description |
|---|---|---|
| getPath(String uuid) | String | Converts a record UUID to a record path. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); System.out.println(ws.record.getPath("5489fc37-3eb7-43de-998c-319725ae0ca0")); } catch (Exception e) { e.printStackTrace(); } }}setNodeClass
Section titled “setNodeClass”Description:
| Method | Return values | Description |
|---|---|---|
| setNodeClass(String uuid, long ncId) | void | Sets the NodeClass. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); long ncId = 2; ws.record.setNodeClass("7ce1b4a8-4ade-4dce-8d7d-4e99a6cd368b", ncId); } catch (Exception e) { e.printStackTrace(); } }}setDispositionStage
Section titled “setDispositionStage”Description:
| Method | Return values | Description |
|---|---|---|
| setDispositionStage(String uuid, long stage) | void | Sets the disposition stage |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); long stage = 1; ws.record.setDispositionStage("7ce1b4a8-4ade-4dce-8d7d-4e99a6cd368b", stage); } catch (Exception e) { e.printStackTrace(); } }}setDescription
Section titled “setDescription”Description:
| Method | Return values | Description |
|---|---|---|
| setDescription(String uuid, String description) | void | Sets a description. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); ws.record.setDescription("7ce1b4a8-4ade-4dce-8d7d-4e99a6cd368b", "some description"); } catch (Exception e) { e.printStackTrace(); } }}extendedCopy
Section titled “extendedCopy”Description:
| Method | Return values | Description |
|---|---|---|
| extendedCopy(String uuid, String dstId, String newName, boolean categories, boolean keywords, boolean propertyGroups, boolean notes, boolean security) | Record | Copies a record with the associated data into a folder or record. |
- The value of the dstId parameter should be a folder or record UUID.
- When the newName parameter value is null, the record will preserve the same name.
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.bean.Record;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); Record record = ws.record.extendedCopy("ada67d44-b081-4b23-bdc1-74181cafbc5d", "8599eab7-ae61-4628-8010-1103d6950c63", "new name record", true, true, true, true, true); System.out.println(record); } catch (Exception e) { e.printStackTrace(); } }}createWizard
Section titled “createWizard”Description:
| Method | Return values | Description |
|---|---|---|
| createWizard(String uuid, String name, String title, long nodeClass) | WizardNode | Creates a new record using a wizard. |
- The parameter uuid should be any valid folder or record UUID.
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.bean.WizardNode;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); WizardNode wn = ws.record.createWizard("1f323e88-64ee-4f57-91e2-9276f8c603f9", "PKI-100200", "new title", 0); System.out.print(wn); } catch (Exception e) { e.printStackTrace(); } }}createFromTemplate
Section titled “createFromTemplate”Description:
| Method | Return values | Description |
|---|---|---|
| createFromTemplate(String uuid, String dstPath, boolean categories, boolean keywords, boolean notes, Map<String, String> properties) |
Record | Creates a new record from the template and returns a Record object. |
- The uuid parameter is the UUID value of the template file.
- The dstPath value is the record destination path.
- When the template uses metadata groups to fill in fields, then these values are mandatory and must be set in the properties parameter.
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.bean.Record;import com.openkm.sdk4j.impl.OKMWebservices;import com.openkm.sdk4j.util.ISO8601;
import java.util.Calendar;import java.util.HashMap;import java.util.Map;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password);
Map<String, String> properties = new HashMap<>(); // okg:tpl 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\" ]");
// Property okg:technology properties.put("okp:technology.comment", "sdk name"); Record record = ws.record.createFromTemplate("9a114b17-7e51-41e7-9d3a-dc7b77e37656", "/okm:root/sdk/recTemplate", true, true, true, properties); System.out.println(record); } catch (Exception e) { e.printStackTrace(); } }}createMissingRecords
Section titled “createMissingRecords”Description:
| Method | Return values | Description |
|---|---|---|
| createMissingRecords(String recPath) | void | Creates missing records. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.impl.OKMWebservices;
public class Test {
public static void main(String[] args) { String host = "http://localhost:8080/openkm"; String user = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
try { ws.login(user, password); ws.record.createMissingRecords("/okm:root/missingrec1/missingrec2/missingrec3"); } catch (Exception e) { e.printStackTrace(); } }}