Note samples

Basics

Example of UUID:

  • Using UUID -> "373bcdd0-c082-4e7b-addd-e10ef813946e";

Suggested code sample

First, you must create the webservice object:

OKMWebservices ws = OKMWebservicesFactory.getInstance(host);

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

ws.login(user, password);

Once you are logged in with the webservices, the session is kept in the webservice object. Then you can use the other API methods.

At this point you can use all the Note methods from the "note" class as shown below:

ws.note.add("373bcdd0-c082-4e7b-addd-e10ef813946e", "the note text");

Methods

add

Description:

MethodReturn valuesDescription

add(String uuid, String text)

Note

Adds a note to a node and returns a Note object.

Example:

package com.openkm;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;

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.note.add("373bcdd0-c082-4e7b-addd-e10ef813946e", "the note text");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

get

Description:

MethodReturn valuesDescription

get(String noteId)

Note

Retrieves the note.

The noteId is a UUID.

The Node object has a variable named path; in that case, the path contains a UUID.

Example:

package com.openkm;

import java.util.List;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Note;

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);
            List<Note> notes = ws.note.list("373bcdd0-c082-4e7b-addd-e10ef813946e");
            if (notes.size() > 0) {
                System.out.println(ws.get(notes.get(0).getPath()));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

delete

Description:

MethodReturn valuesDescription

delete(String noteId)

Note

Deletes a note.

The noteId is a UUID.

The Node object has a variable named path; in that case, the path contains a UUID.

Example:

package com.openkm;

import java.util.List;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Note;

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);
            List<Note> notes = ws.note.list("373bcdd0-c082-4e7b-addd-e10ef813946e");
            if (notes.size() > 0) {
                ws.note.delete(notes.get(0).getPath());
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

set

Description:

MethodReturn valuesDescription

set(String noteId, String text)

void

Changes the note text.

The noteId is a UUID.

The Node object has a variable named path; in that case, the path contains a UUID.

Example:

package com.openkm;

import java.util.List;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Note;

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);
            List<Note> notes = ws.note.list("373bcdd0-c082-4e7b-addd-e10ef813946e");
            if (notes.size() > 0) {
                ws.note.set(notes.get(0).getPath(), "text modified");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

list

Description:

MethodReturn valuesDescription

list(String uuid)

List<Note>

Retrieves a list of all notes of a node.

Example:

package com.openkm;

import java.util.List;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.Note;

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);
            List<Note> notes = ws.note.list("373bcdd0-c082-4e7b-addd-e10ef813946e");
            for (Note note : notes) {
                System.out.println(note);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getNoteHistories

Description:

MethodReturn valuesDescription

getNoteHistories(String uuid)

List<NoteHistory>

Returns the historical notes of a node.

Example:

package com.openkm;

import java.util.List;

import com.openkm.sdk4j.OKMWebservices;
import com.openkm.sdk4j.OKMWebservicesFactory;
import com.openkm.sdk4j.bean.NoteHistory;

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);
            List<NoteHistory> list = ws.note.getNoteHistories("3c68b3a1-c65c-4b1e-84b5-9ce2712ca573");
            for (NoteHistory noteHistory : list) {
                System.out.println(noteHistory);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}