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 should login using the method "login". You can access the "login" method from webservice object "ws" as is shown below:
ws.login(user, password);
Once you are logged with the webservices the session is keep in the webservice Object. Then you can use the other API method
At this point you can use all the Note methods from "note" class as is shown below:
ws.note.addNote("373bcdd0-c082-4e7b-addd-e10ef813946e", "the note text");
Methods
addNote
Description:
Method | Return values | Description |
---|---|---|
addNote(String uuid, String text) |
Note |
Adds a note to a node and returns an object Note. |
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.addNote("373bcdd0-c082-4e7b-addd-e10ef813946e", "the note text");
} catch (Exception e) {
e.printStackTrace();
}
}
}
getNote
Description:
Method | Return values | Description |
---|---|---|
getNote(String noteId) |
Note |
Retrieves the note. |
The noteId is an UUID. The object Node has a variable named path, in that case the path contains an 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.listNotes("373bcdd0-c082-4e7b-addd-e10ef813946e");
if (notes.size() > 0) {
System.out.println(ws.getNote(notes.get(0).getPath()));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
deleteNote
Description:
Method | Return values | Description |
---|---|---|
deleteNote(String noteId) |
Note |
Delete a note. |
The noteId is an UUID. The object Node has a variable named path, in that case the path contains an 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.listNotes("373bcdd0-c082-4e7b-addd-e10ef813946e");
if (notes.size() > 0) {
ws.note.deleteNote(notes.get(0).getPath());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
setNote
Description:
Method | Return values | Description |
---|---|---|
setNote(String noteId, String text) |
void |
Changes the note text. |
The noteId is an UUID. The object Node has a variable named path, in that case the path contains an 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.listNotes("373bcdd0-c082-4e7b-addd-e10ef813946e");
if (notes.size() > 0) {
ws.note.setNote(notes.get(0).getPath(), "text modified");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
listNotes
Description:
Method | Return values | Description |
---|---|---|
listNotes(String uuid) |
List<Note> |
Retrieves a list of all the 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.listNotes("373bcdd0-c082-4e7b-addd-e10ef813946e");
for (Note note : notes) {
System.out.println(note);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
getNotesHistory
Description:
Method | Return values | Description |
---|---|---|
getNotesHistory(String uuid) |
List<NoteHistory> |
Return 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.getNotesHistory("3c68b3a1-c65c-4b1e-84b5-9ce2712ca573");
for (NoteHistory noteHistory : list) {
System.out.println(noteHistory);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}