Record samples
Basics
Example of UUID:
- Using UUID -> "a66664a3-0e1d-4b03-9049-a2f4732a0802";
Suggested code sample
First, you must create the web service object:
OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
Then you should log in using the method "login". You can access the "login" method from the web service object "ws" as shown below:
ws.login(user, password);
Once you are logged in to the web services, the session is kept in the web service object. Then you can use the other API methods.
At this point you can use all the Record methods from "record" class as shown below:
ws.record.createRecord("ada67d44-b081-4b23-bdc1-74181cafbc5d", "PKI-100200", "new title", 0)
Methods
createRecord
Description:
Method | Return values | Description |
---|---|---|
createRecord(String uuid, String name, String title, long nodeClass) |
Record |
Creates a new record and returns a Record object. |
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.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.createRecord("ada67d44-b081-4b23-bdc1-74181cafbc5d", "PKI-100200", "new title", 0);
System.out.println(record);
} catch (Exception e) {
e.printStackTrace();
}
}
}
getRecordProperties
Description:
Method | Return values | Description |
---|---|---|
getRecordProperties(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.getRecordProperties("fbe2933e-b141-4557-ab7a-736820ecdb2e"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
deleteRecord
Description:
Method | Return values | Description |
---|---|---|
deleteRecord(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.deleteRecord("fbe2933e-b141-4557-ab7a-736820ecdb2e");
} catch (Exception e) {
e.printStackTrace();
}
}
}
purgeRecord
Description:
Method | Return values | Description |
---|---|---|
purgeRecord(String uuid) |
void |
The record is definitively removed from the repository. |
Usually you will purge records to /okm:trash/userId - the personal trash user location - but it is possible to directly purge any record from the whole repository. When a record is purged it can only be restored from a previous repository backup. The purge action removes the record permanently 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.purgeRecord("fbe2933e-b141-4557-ab7a-736820ecdb2e");
} catch (Exception e) {
e.printStackTrace();
}
}
}
renameRecord
Description:
Method | Return values | Description |
---|---|---|
renameRecord(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.renameRecord("5489fc37-3eb7-43de-998c-319725ae0ca0", "new_name");
} catch (Exception e) {
e.printStackTrace();
}
}
}
moveRecord
Description:
Method | Return values | Description |
---|---|---|
moveRecord(String uuid, String dstId) |
void |
Moves a record to a folder or record. |
The values of the dstId parameter should be a folder or record UUID. |
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.moveRecord("5489fc37-3eb7-43de-998c-319725ae0ca0", "8599eab7-ae61-4628-8010-1103d6950c63");
} catch (Exception e) {
e.printStackTrace();
}
}
}
copyRecord
Description:
Method | Return values | Description |
---|---|---|
copyRecord(String uuid, String dstId, String newName) |
void |
Copies a record to a folder or record. |
The values of the dstId parameter should be a folder or record UUID. When the parameter newName value is null, the record will retain the same name. Only the security grants are copied to the destination; the metadata, keywords, etc., of the record are not copied. |
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.copyRecord("5489fc37-3eb7-43de-998c-319725ae0ca0", "8599eab7-ae61-4628-8010-1103d6950c63", "PKI-100200");
} catch (Exception e) {
e.printStackTrace();
}
}
}
isValidRecord
Description:
Method | Return values | Description |
---|---|---|
isValidRecord(String uuid) |
Boolean |
Returns a boolean that indicates whether the node is a record or not. |
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.isValidRecord("5489fc37-3eb7-43de-998c-319725ae0ca0"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
getRecordChildren
Description:
Method | Return values | Description |
---|---|---|
getRecordChildren(String uuid) |
List<Record> |
Returns a list of all records whose parent is fldId. |
The parameter uuid can be a folder or a record node. |
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.getRecordChildren("8599eab7-ae61-4628-8010-1103d6950c63")) {
System.out.println(rec);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
setRecordTitle
Description:
Method | Return values | Description |
---|---|---|
setRecordTitle(String uuid, String title) |
void |
Sets a record's 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.setRecordTitle("5489fc37-3eb7-43de-998c-319725ae0ca0", "some title");
} catch (Exception e) {
e.printStackTrace();
}
}
}
getRecordPath
Description:
Method | Return values | Description |
---|---|---|
getRecordPath(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.getRecordPath("5489fc37-3eb7-43de-998c-319725ae0ca0"));
} catch (Exception e) {
e.printStackTrace();
}
}
}
setRecordDescription
Description:
Method | Return values | Description |
---|---|---|
setRecordDescription(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.setRecordDescription("7ce1b4a8-4ade-4dce-8d7d-4e99a6cd368b", "some description");
} catch (Exception e) {
e.printStackTrace();
}
}
}
extendedRecordCopy
Description:
Method | Return values | Description |
---|---|---|
extendedRecordCopy(String uuid, String dstId, String newName, boolean categories, boolean keywords, boolean propertyGroups, boolean notes, boolean security) |
Record |
Copies a record with its associated data into a folder or record. |
The values of the dstId parameter should be a folder or record UUID. When the parameter newName value is null, the record will retain the same name. By default only the binary data and the security grants are copied; the metadata, keywords, etc. of the folder are not copied. Additional:
|
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.extendedRecordCopy("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();
}
}
}
createWizardRecord
Description:
Method | Return values | Description |
---|---|---|
createWizardRecord(String uuid, String name, String title, long nodeClass) |
WizardNode |
Creates a new record with a wizard. |
The parameters uuid should be any valid folder or record UUID. The WizardNode contains a list of pending actions that should be done to complete the process of record creation. These might be:
|
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.createWizardRecord("1f323e88-64ee-4f57-91e2-9276f8c603f9", "PKI-100200", "new title", 0);
System.out.print(wn);
} catch (Exception e) {
e.printStackTrace();
}
}
}
createRecordFromTemplate
Description:
Method | Return values | Description |
---|---|---|
createRecordFromTemplate(String uuid, String dstPath, boolean categories, |
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, these values are mandatory and must be set in the properties parameter. Additional:
|
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.createRecordFromTemplate("9a114b17-7e51-41e7-9d3a-dc7b77e37656", "/okm:root/sdk/recTemplate", true, true, true, properties);
System.out.println(record);
} catch (Exception e) {
e.printStackTrace();
}
}
}
createMissingRecords
Description:
Method | Return values | Description |
---|---|---|
createMissingRecords(String recPath) |
String |
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();
}
}
}