Record samples
On most methods you’ll see parameter named “recId”. The value of this parameter can be a valid record UUID or path.
Methods
Section titled “Methods”createRecord
Section titled “createRecord”Description:
| Method | Return values | Description |
|---|---|---|
| createRecord(Record record) | Record | Creates a new record and return as a result an object Record. |
The variable path in the parameter record, must be initializated. It indicates the folder path into OpenKM.
Record record = new Record();record.setPath("/okm:root/PKI-100200");Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservices;import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.bean.Record;
public class Test { public static void main(String[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try { Record record = new Record(); record.setPath("/okm:root/PKI-100200"); record.setTitle("some title"); ws.createRecord(record); } catch (Exception e) { e.printStackTrace(); } }}getRecordProperties
Section titled “getRecordProperties”Description:
| Method | Return values | Description |
|---|---|---|
| getRecordProperties(String recId) | Record | Returns the record properties. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservices;import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test { public static void main(String[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try { System.out.println(ws.getRecordProperties("/okm:root/PKI-100200")); } catch (Exception e) { e.printStackTrace(); } }}deleteRecord
Section titled “deleteRecord”Description:
| Method | Return values | Description |
|---|---|---|
| deleteRecord(String recId) | void | Deletes a record. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservices;import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test { public static void main(String[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try { ws.deleteRecord("/okm:root/PKI-100200"); } catch (Exception e) { e.printStackTrace(); } }}purgeRecord
Section titled “purgeRecord”Description:
| Method | Return values | Description |
|---|---|---|
| purgeRecord(String recId) | void | The record is definetivelly removed from repository. |
Usually you will purge records to /okm:trash/userId - the personal trash user locations - but is possible to directly purge any record from the whole repository.
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservices;import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test { public static void main(String[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try { ws.purgeRecord("/okm:trash/okmAdmin/PKI-100200"); } catch (Exception e) { e.printStackTrace(); } }}renameRecord
Section titled “renameRecord”Description:
| Method | Return values | Description |
|---|---|---|
| renameRecord(String recId, String newName) | Record | Renames a record. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservices;import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test { public static void main(String[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try { ws.renameRecord("/okm:root/PKI-100200", "new_name"); } catch (Exception e) { e.printStackTrace(); } }}moveRecord
Section titled “moveRecord”Description:
| Method | Return values | Description |
|---|---|---|
| moveRecord(String recId, String dstId) | void | Moves a record to a 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.sdk4j.OKMWebservices;import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test { public static void main(String[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try { ws.moveRecord("/okm:root/PKI-100200", "/okm:root/tmp"); } catch (Exception e) { e.printStackTrace(); } }}copyRecord
Section titled “copyRecord”Description:
| Method | Return values | Description |
|---|---|---|
| copyRecord(String recId, 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 or path.
When the parameter newName value is null, the record will preserve the same name.
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservices;import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test { public static void main(String[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try { ws.copyRecord("/okm:root/PKI-100200", "/okm:root/tmp", "new_name"); } catch (Exception e) { e.printStackTrace(); } }}isValidRecord
Section titled “isValidRecord”Description:
| Method | Return values | Description |
|---|---|---|
| isValidRecord(String recId) | Boolean | Returns a boolean that indicate if the node is a record or not. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservices;import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test { public static void main(String[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try { System.out.println("Is a record:" + ws.isValidRecord("/okm:root/PKI-100200")); } catch (Exception e) { e.printStackTrace(); } }}getRecordChildren
Section titled “getRecordChildren”Description:
| Method | Return values | Description |
|---|---|---|
| getRecordChildren(String fldId) | List |
Returns a list of all records which their parent is fldId |
The parameter fldId can be a folder or a record node.
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservices;import com.openkm.sdk4j.OKMWebservicesFactory;import com.openkm.sdk4j.bean.Record;
public class Test { public static void main(String[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try { for (Record rec : ws.getRecordChildren("/okm:root/folder")) { System.out.println(rec); } } catch (Exception e) { e.printStackTrace(); } }}lockRecord
Section titled “lockRecord”Description:
| Method | Return values | Description |
|---|---|---|
| lockRecord(String recId) | LockInfo | Locks a record and return an object with the Lock information |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservices;import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test { public static void main(String[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try { ws.lockRecord("/okm:root/PKI-100200"); } catch (Exception e) { e.printStackTrace(); } }}unlockRecord
Section titled “unlockRecord”Description:
| Method | Return values | Description |
|---|---|---|
| unlockRecord(String recId) | void | Unlock a locked record. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservices;import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test { public static void main(String[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try { ws.unlockRecord("/okm:root/PKI-100200"); } catch (Exception e) { e.printStackTrace(); } }}forceUnlockRecord
Section titled “forceUnlockRecord”Description:
| Method | Return values | Description |
|---|---|---|
| forceUnlockRecord(String recId) | void | Unlocks a locked record. |
This method allows to unlock any locked record.
It is not mandatory to execute this action by the same user who previously executed the checkout lock action.
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservices;import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test { public static void main(String[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try { ws.forceUnlockRecord("/okm:root/PKI-100200"); } catch (Exception e) { e.printStackTrace(); } }}setRecordTitle
Section titled “setRecordTitle”Description:
| Method | Return values | Description |
|---|---|---|
| setRecordTitle(String recId, String title) | void | Sets a record title. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservices;import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test { public static void main(String[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try { ws.setRecordTitle("/okm:root/PKI-100200","some title"); } catch (Exception e) { e.printStackTrace(); } }}getRecordPath
Section titled “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.OKMWebservices;import com.openkm.sdk4j.OKMWebservicesFactory;
public class Test { public static void main(String[] args) { String host = "http://localhost:8080/OpenKM"; String username = "okmAdmin"; String password = "admin"; OKMWebservices ws = OKMWebservicesFactory.newInstance(host, username, password);
try { System.out.println(ws.getRecordPath("a66664a3-0e1d-4b03-9049-a2f4732a0802")); } catch (Exception e) { e.printStackTrace(); } }}