Bookmark samples

Basics

Suggested code sample

First, you must create the web service object:

OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

Then you should log in using the method "login". You can access the "login" method from the web service object "ws" as shown below:

ws.login(user, password);

Once you are logged in to the web service, the session is kept in the web service 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:

MethodReturn valuesDescription

getUserBookmarks()

List<Bookmark>

Returns a list of all bookmarks for 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();
        }
    }
}

create

Description:

MethodReturn valuesDescription

create(String uuid, String name)

void

Create 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.create("a37f570f-5e7f-4a03-8d04-9b3689be82f1", "test bookmark");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

rename

Description:

MethodReturn valuesDescription

rename(int bookmarkId, String name)

void

Rename 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.rename(bookmarkId, "set bookmark");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

delete

Description:

MethodReturn valuesDescription

delete(int bookmarkId)

void

Delete 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.delete(bookmarkId);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}