Notification samples

Basics

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 Notification methods from "notification" class as is shown below:

ws.notification.notify(uuids, users, roles, mails, message, false);

Methods

notify

Description:

MethodReturn valuesDescription

notify(List<String> uuids, List<String> users, List<String> roles, List<String> mails, String message, boolean attachment)

void

Send a mail notification.

The parameter uuids are the UUID of the node ( document, folder, mail or record ).

The parameter users are a set of OpenKM users to be notified.

The parameter roles are a set of OpenKM roles to be notified.

The parameter mails are a set of email addresses - usually external mails - to be notified.

The parameter message is the content body of the mail.

When attachment value is true the node is attached into 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();
        }
    }
}