Notification samples
Basics
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 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 Notification methods from the "notification" class as shown below:
ws.notification.notify(uuids, users, roles, mails, message, false);
Methods
notify
Description:
Method | Return values | Description |
---|---|---|
notify(List<String> uuids, List<String> users, List<String> roles, List<String> mails, String message, boolean attachment) |
void |
Sends a mail notification. |
The parameter uuids are the UUIDs of the nodes (document, folder, mail, or record). The parameter users is a set of OpenKM users to be notified. The parameter roles is a set of OpenKM roles to be notified. The parameter mails is a set of email addresses, usually external, to be notified. The parameter message is the body of the mail. When the attachment value is true, the node is attached to the mail. |
Example:
package com.openkm;
import java.util.ArrayList;
import java.util.List;
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);
List<String> uuids = new ArrayList<>();
uuids.add("b153c4b7-3d1c-4589-bd42-0ed0f34fd338");
List<String> users = new ArrayList<>();
users.add("test");
users.add("sochoa");
List<String> roles = new ArrayList<>();
roles.add("ROLE_TEST");
List<String> mails = new ArrayList<>();
String message = "Body of the message";
ws.notification.notify(uuids, users, roles, mails, message, false);
} catch (Exception e) {
e.printStackTrace();
}
}
}