OKMBookmark
Used for managing bookmarks of users. For example add or remove bookmark of a node for a user.
Basics
On almost methods you'll see parameter named "nodeId". The value of this parameter can be some valid node UUID ( folder, document, mail, record ).
Example of nodeId:
- Using UUID -> "3887ae75-dd67-4019-b4d1-2f6962815403";
Also on all methods you'll see parameter named "token". Because the Cron Task are executed in background without authentication, the methods used in this scenario might use the token parameter. 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
add
Description:
Method | Return values | Description |
---|---|---|
add(String token, String nodeId, String name) |
Bookmark |
Add a new bookmark of a node. |
The parameter name indicates the name which will be used to store the bookmark. Usually is used the same name of the nodeId. |
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();
}
}
}
get
Description:
Method | Return values | Description |
---|---|---|
get(String token, int bmId) |
Bookmark |
Gets the bookmark data. |
The parameter bmId is the value of the unique bookmark identifier. |
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
Description:
Method | Return values | Description |
---|---|---|
remove(String token, int bmId) |
void |
Delete a bookmark. |
The parameter bmId is the value of the unique bookmark identifier. |
Example:
package com.openkm;
import com.openkm.api.OKMBookmark;
public class Test {
public static void main(String[] args) {
try {
int bmId = 23;
OKMBookmark.getInstance().remove(null, bmId);
} catch (Exception e) {
e.printStackTrace();
}
}
}
rename
Description:
Method | Return values | Description |
---|---|---|
rename(String token, int bmId, String newName |
Bookmark |
Rename a bookmark. |
The parameter bmId is the value of the unique bookmark identifier. |
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
Description:
Method | Return values | Description |
---|---|---|
getAll(String token) |
List<Bookmark> |
Gets all the bookmarks of the logged 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();
}
}
}