OKMRecord
Basics
On almost methods you'll see parameter named "recId". The value of this parameter can be some valid record UUID or path.
Example of recId:
- Using UUID -> "c52f9ea0-0d6c-45da-bae4-d72b66f42da3";
- Using path -> "/okm:root/test"
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".
On special cases you might be "promoted as Administrator" using the "administrator token".
String systemToken = DbSessionManager.getInstance().getSystemToken();
Methods
create
Description:
Method | Return values | Description |
---|---|---|
create(String token, Record rec) |
Record |
Creates a new record and returns as a result an object Record. |
The variable path into the parameter rec, must be initializated. It indicates the folder path into OpenKM.
The other variables of the Record ( rec ) will not take any effect on the record creation. We suggest using the method below to create the Record Simply rather this one. |
Example:
package com.openkm;
import com.openkm.api.OKMRecord;
import com.openkm.bean.Record;
public class Test {
public static void main(String[] args) {
try {
Record rec = new Record();
rec.setPath("/okm:root/test");
OKMRecord.getInstance().create(null, rec);
} catch (Exception e) {
e.printStackTrace();
}
}
}
createSimple
Description:
Method | Return values | Description |
---|---|---|
createSimple(String token, String recPath) |
Record |
Creates a new record and returns as a result an object Record. |
Example:
package com.openkm;
import com.openkm.api.OKMRecord;
public class Test {
public static void main(String[] args) {
try {
String recPath = "/okm:root/PKI-100200";
OKMRecord.getInstance().createSimple(null, recPath);
} catch (Exception e) {
e.printStackTrace();
}
}
}
getProperties
Description:
Method | Return values | Description |
---|---|---|
getProperties(String token, String recId) |
Record |
Return the record properties. |
Example:
package com.openkm;
import com.openkm.api.OKMRecord;
import com.openkm.bean.Record;
public class Test {
public static void main(String[] args) {
try {
Record rec = OKMRecord.getInstance().getProperties(null, "/okm:root/PKI-100200");
System.out.println(rec);
} catch (Exception e) {
e.printStackTrace();
}
}
}
delete
Description:
Method | Return values | Description |
---|---|---|
delete(String token, String recId) |
void |
Delete a record. |
Example:
package com.openkm;
import com.openkm.api.OKMRecord;
public class Test {
public static void main(String[] args) {
try {
OKMRecord.getInstance().delete(null, "/okm:root/PKI-100200");
} catch (Exception e) {
e.printStackTrace();
}
}
}
purge
Description:
Method | Return values | Description |
---|---|---|
purge(String token, String recId) |
void |
The record is definitely removed from the repository. |
Usually you will purge folders into /okm:trash/userId - the personal trash user locations - but it is possible to directly purge any record from the whole repository. When a record is purged, it will only be able to be restored from a previously repository backup. The purge action removes the record definitely from the repository. |
Example:
package com.openkm;
import com.openkm.api.OKMRecord;
public class Test {
public static void main(String[] args) {
try {
OKMRecord.getInstance().purge(null, "/okm:root/PKI-100200");
} catch (Exception e) {
e.printStackTrace();
}
}
}
rename
Description:
Method | Return values | Description |
---|---|---|
rename(String token, String recId, String newName) |
Record |
Rename a record. |
Example:
package com.openkm;
import com.openkm.api.OKMRecord;
public class Test {
public static void main(String[] args) {
try {
OKMRecord.getInstance().rename(null, "/okm:root/test", "newname");
} catch (Exception e) {
e.printStackTrace();
}
}
}
move
Description:
Method | Return values | Description |
---|---|---|
move(String token, String recId, String dstId) |
void |
Moves record 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.OKMRecord;
public class Test {
public static void main(String[] args) {
try {
OKMRecord.getInstance().move(null, "/okm:root/PKI-100200", "/okm:root/move/destination");
} catch (Exception e) {
e.printStackTrace();
}
}
}
copy
Description:
Method | Return values | Description |
---|---|---|
copy(String token, String recId, String dstId) |
void |
Copies a record into a folder or record. |
The values of the dstId parameter should be a folder or record UUID or path. Only the binary data and the security grants are copied to destination, the metadata, keywords, etc. of the document are not copied. See "extendedCopy" method for this feature. |
Example:
package com.openkm;
import com.openkm.api.OKMRecord;
public class Test {
public static void main(String[] args) {
try {
OKMRecord.getInstance().copy(null, "/okm:root/PKI-100200", "/okm:root/move/destination");
} catch (Exception e) {
e.printStackTrace();
}
}
}
copy
Description:
Method | Return values | Description |
---|---|---|
copy(String token, String recId, String dstId, String newName) |
void |
Copies a record into a folder or record. |
The values of the dstId parameter should be a folder or record UUID or path. When parameter newName value is null, folder will preservate the same name. Only the binary data and the security grants are copied to destination, the metadata, keywords, etc. of the document are not copied. See "extendedCopy" method for this feature. |
Example:
package com.openkm;
import com.openkm.api.OKMRecord;
public class Test {
public static void main(String[] args) {
try {
OKMRecord.getInstance().copy(null, "/okm:root/PKI-100200", "/okm:root/move/destination", "newname");
} catch (Exception e) {
e.printStackTrace();
}
}
}
extendedCopy
Description:
Method | Return values | Description |
---|---|---|
extendedCopy(String token, String recId, String dstId, String newName, ExtendedAttributes extAttr) |
void |
Copies a record 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 newName value is null, the record will preserve the same name. By default only the binary data and the security grants, the metadata, keywords, etc. of the document are not copied. Additional:
|
Example:
package com.openkm;
import com.openkm.api.OKMRecord;
import com.openkm.bean.ExtendedAttributes;
public class Test {
public static void main(String[] args) {
try {
ExtendedAttributes extAttr = new ExtendedAttributes();
// copy keywords
extAttr.setKeywords(true);
OKMRecord.getInstance().extendedCopy(null, "/okm:root/records/rec-0012343", "/okm:root/temp", "rec-0012344", extAttr);
} catch (Exception e) {
e.printStackTrace();
}
}
}
isValid
Description:
Method | Return values | Description |
---|---|---|
isValid(String token, String recId) |
boolean |
Returns a boolean that indicates if the node is a record or not. |
Example:
package com.openkm;
import com.openkm.api.OKMRecord;
public class Test {
public static void main(String[] args) {
try {
boolean valid = OKMRecord.getInstance().isValid(null, "/okm:root/PKI-100200");
System.out.println(valid);
} catch (Exception e) {
e.printStackTrace();
}
}
}
getPath
Description:
Method | Return values | Description |
---|---|---|
getPath(String token, String recId) |
String |
Convert folder UUID to record path. |
Example:
package com.openkm;
import com.openkm.api.OKMRecord;
public class Test {
public static void main(String[] args) {
try {
String path = OKMRecord.getInstance().getPath(null, "/okm:root/PKI-100200");
System.out.println(path);
} catch (Exception e) {
e.printStackTrace();
}
}
}
getChildren
Description:
Method | Return values | Description |
---|---|---|
getChildren(String token, String fldId) |
List<Record> |
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.api.OKMRecord;
import com.openkm.bean.Record;
public class Test {
public static void main(String[] args) {
try {
for (Record rec : OKMRecord.getInstance().getChildren(null, "/okm:root/PKI-100200")) {
System.out.println(rec);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
lock
Description:
Method | Return values | Description |
---|---|---|
lock(String token, String recId) |
LockInfo |
Locks a record and return an object with the Lock information. |
Only the user who locked the record is allowed to unlock. A locked record can not be modified by other users. |
Example:
package com.openkm;
import com.openkm.api.OKMRecord;
public class Test {
public static void main(String[] args) {
try {
OKMRecord.getInstance().lock(null, "/okm:root/PKI-100200");
} catch (Exception e) {
e.printStackTrace();
}
}
}
unlock
Description:
Method | Return values | Description |
---|---|---|
lock(String token, String recId) |
LockInfo |
Unlock a locked record. |
Only the user who locked the record is allowed to unlock. |
Example:
package com.openkm;
import com.openkm.api.OKMRecord;
public class Test {
public static void main(String[] args) {
try {
OKMRecord.getInstance().unlock(null, "/okm:root/PKI-100200");
} catch (Exception e) {
e.printStackTrace();
}
}
}
forceUnlock
Description:
Method | Return values | Description |
---|---|---|
forceUnlock(String token, String recId) |
void |
Unlock 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. This action can only be done by a super user ( user with ROLE_ADMIN ). |
Example:
package com.openkm;
import com.openkm.api.OKMRecord;
public class Test {
public static void main(String[] args) {
try {
OKMRecord.getInstance().forceUnlock(null, "/okm:root/PKI-100200");
} catch (Exception e) {
e.printStackTrace();
}
}
}
setTitle
Description:
Method | Return values | Description |
---|---|---|
setTitle(String token, String recId, String title) |
void |
Sets a record title. |
Example:
package com.openkm;
import com.openkm.api.OKMRecord;
public class Test {
public static void main(String[] args) {
try {
OKMRecord.getInstance().setTitle(null, "/okm:root/PKI-100200", "title");
} catch (Exception e) {
e.printStackTrace();
}
}
}