Skip to content

OKMNote

In most methods you’ll see a parameter named “nodeId”. The value of this parameter can be a valid document, folder, mail, or record UUID.

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 must use the “user session”.

Description:

Method Return values Description
add(String token, String nodeId, String text) Note Adds a note to a node and returns a Note object.

Example:

package com.openkm;
import com.openkm.api.OKMNote;
import com.openkm.bean.Note;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMNote okmNote = ContextWrapper.getContext().getBean(OKMNote.class);
Note note = okmNote.add(null, "f123a950-0329-4d62-8328-0ff500fd42db", "the note text");
System.out.println(note);
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
get(String token, String noteId) Note Retrieves the note.

Example:

package com.openkm;
import com.openkm.api.OKMNote;
import com.openkm.bean.Note;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMNote okmNote = ContextWrapper.getContext().getBean(OKMNote.class);
for (Note note : okmNote.list(null, "f123a950-0329-4d62-8328-0ff500fd42db")) {
Note data = okmNote.get(null, note.getPath());
System.out.println(data);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
delete(String token, String noteId) void Deletes a note.

Example:

package com.openkm;
import com.openkm.api.OKMNote;
import com.openkm.bean.Note;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMNote okmNote = ContextWrapper.getContext().getBean(OKMNote.class);
for (Note note : okmNote.list(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338")) {
okmNote.delete(null, note.getPath());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
set(String token, String noteId, String text) String Changes the note’s text. Returns the updated text.

Example:

package com.openkm;
import com.openkm.api.OKMNote;
import com.openkm.bean.Note;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMNote okmNote = ContextWrapper.getContext().getBean(OKMNote.class);
for (Note note : okmNote.list(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338")) {
String updated = okmNote.set(null, note.getPath(), "new note");
System.out.println(updated);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
list(String token, String nodeId) List Retrieves a list of all the notes for a node.

Example:

package com.openkm;
import com.openkm.api.OKMNote;
import com.openkm.bean.Note;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMNote okmNote = ContextWrapper.getContext().getBean(OKMNote.class);
for (Note note : okmNote.list(null, "b153c4b7-3d1c-4589-bd42-0ed0f34fd338")) {
System.out.println(note);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}

Description:

Method Return values Description
getNoteHistories(String token, String nodeId) List Returns the historical notes of a node.

Example:

package com.openkm;
import com.openkm.api.OKMNote;
import com.openkm.bean.NoteHistory;
import com.openkm.util.ContextWrapper;
public class Test {
public static void main(String[] args) {
try {
OKMNote okmNote = ContextWrapper.getContext().getBean(OKMNote.class);
for (NoteHistory noteHistory : okmNote.getNoteHistories(null, "3c68b3a1-c65c-4b1e-84b5-9ce2712ca573")) {
System.out.println(noteHistory);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}