Bookmark samples
Basics
Suggested code sample
First, you must create the webservice object:
OKMWebservices ws = OKMWebservicesFactory.getInstance(host);
Then you should log in using the "login" method. You can access the "login" method from the webservice object "ws" as shown below:
ws.login(user, password);
Once you are logged in to the webservice, the session is kept in the webservice object. Then you can use the other API methods.
At this point you can use all the bookmark methods from the "bookmark" class as shown below:
ws.bookmark.getUserBookmarks()
Methods
getUserBookmarks
Description:
Method | Return values | Description |
---|---|---|
getUserBookmarks() |
List<Bookmark> |
Returns a list of all the bookmarks of a user. |
Example:
package com.openkm;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Bookmark;
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 (Bookmark bookmark : ws.bookmark.getUserBookmarks()) {
System.out.println(bookmark);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
createBookmark
Description:
Method | Return values | Description |
---|---|---|
createBookmark(String uuid, String name) |
void |
Creates a new bookmark. |
The value of the uuid is the UUID of the node (document, folder, mail or 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.bookmark.createBookmark("a37f570f-5e7f-4a03-8d04-9b3689be82f1", "test bookmark");
} catch (Exception e) {
e.printStackTrace();
}
}
}
renameBookmark
Description:
Method | Return values | Description |
---|---|---|
renameBookmark(int bookmarkId, String name) |
void |
Renames a bookmark. |
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);
int bookmarkId = 1;
ws.bookmark.renameBookmark(bookmarkId, "set bookmark");
} catch (Exception e) {
e.printStackTrace();
}
}
}
deleteBookmark
Description:
Method | Return values | Description |
---|---|---|
deleteBookmark(int bookmarkId) |
void |
Deletes a bookmark. |
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);
int bookmarkId = 1;
ws.bookmark.deleteBookmark(bookmarkId);
} catch (Exception e) {
e.printStackTrace();
}
}
}