OKMBookmark
Used to manage bookmarks for users. For example, add or remove a bookmark on a node for a user.
Basics
Section titled “Basics”In most methods you’ll see a parameter named “nodeId”. The value of this parameter can be a valid node UUID (folder, document, mail, record).
Also, in all methods you’ll see a parameter named “token”. Because Cron tasks are executed in the background without authentication, the methods used in this scenario might use the token parameter. In the default application execution context, you must use the “null” value, which indicates that the application should use the “user session”.
Methods
Section titled “Methods”Description:
| Method | Return values | Description |
|---|---|---|
| add(String token, String nodeId, String name) | Bookmark | Adds a new bookmark for a node. |
Example:
package com.openkm;
import com.openkm.api.OKMBookmark;import com.openkm.db.bean.Bookmark;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMBookmark okmBookmark = ContextWrapper.getContext().getBean(OKMBookmark.class); Bookmark bookmark = okmBookmark.add(null, "3887ae75-dd67-4019-b4d1-2f6962815403", "document.doc"); System.out.println(bookmark); } catch (Exception e) { e.printStackTrace(); } }}Description:
| Method | Return values | Description |
|---|---|---|
| get(String token, int bmId) | Bookmark | Gets the bookmark data. |
Example:
package com.openkm;
import com.openkm.api.OKMBookmark;import com.openkm.db.bean.Bookmark;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMBookmark okmBookmark = ContextWrapper.getContext().getBean(OKMBookmark.class); int bmId = 2; Bookmark bookmark = okmBookmark.get(null, bmId); System.out.println(bookmark); } catch (Exception e) { e.printStackTrace(); } }}remove
Section titled “remove”Description:
| Method | Return values | Description |
|---|---|---|
| remove(String token, int bmId) | void | Deletes a bookmark. |
Example:
package com.openkm;
import com.openkm.api.OKMBookmark;import com.openkm.util.ContextWrapper;
public class Test { public static void main(String[] args) { try { OKMBookmark okmBookmark = ContextWrapper.getContext().getBean(OKMBookmark.class); int bmId = 23; okmBookmark.remove(null, bmId); } catch (Exception e) { e.printStackTrace(); } }}rename
Section titled “rename”Description:
| Method | Return values | Description |
|---|---|---|
| rename(String token, int bmId, String newName) | Bookmark | Renames a bookmark. |
Example:
package com.openkm;
import com.openkm.api.OKMBookmark;import com.openkm.db.bean.Bookmark;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMBookmark okmBookmark = ContextWrapper.getContext().getBean(OKMBookmark.class); int bmId = 2; Bookmark bookmark = okmBookmark.rename(null, bmId, "newname.doc"); System.out.println(bookmark); } catch (Exception e) { e.printStackTrace(); } }}getAll
Section titled “getAll”Description:
| Method | Return values | Description |
|---|---|---|
| getAll(String token) | List |
Gets all the bookmarks of the logged-in user. |
Example:
package com.openkm;
import com.openkm.api.OKMBookmark;import com.openkm.db.bean.Bookmark;import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) { try { OKMBookmark okmBookmark = ContextWrapper.getContext().getBean(OKMBookmark.class); for (Bookmark bookmark : okmBookmark.getAll(null)) { System.out.println(bookmark); } } catch (Exception e) { e.printStackTrace(); } }}