OKMNotification

Basics

On most methods you'll see parameter named "nodeId". The value of this parameter can be a valid document, folder, or mail UUID or path node.

Example of nodeId:

  • Using path -> "/okm:root/logo.png"
  • Using uuid -> "33584fe7-01fc-4ba8-883b-be6979796093"

About the parameter named "nodePath",  the value of this parameter can be a valid document, folder, or mail path node.

Example of nodePath:

  • Using path -> "/okm:root/logo.png"

Also on all methods you'll see parameter named "token". When accessing application across SOAP the login process returns a token, what is used to identify the user on all the exposed methods. From default application execution context you must use "null" value what indicates to the application must use the "user session".

On special cases you might be "promoted as Administrator" using the "administrator token".

String systemToken = DbSessionManager.getInstance().getSystemToken();

Methods

subscribe

Description:

MethodReturn valuesDescription

subscribe(String token, String nodePath)

void

Adds a subscription to a node.

Example:

package com.openkm;

import com.openkm.api.OKMNotification;

public class Test {
    public static void main(String[] args) {
        try {           
            OKMNotification.getInstance().subscribe(null, "/okm:root/logo.png");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

subscribe

Description:

MethodReturn valuesDescription

unsubscribe(String token, String nodePath)

void

Delete a subscription to a node.

Example:

package com.openkm;

import com.openkm.api.OKMNotification;

public class Test {
    public static void main(String[] args) {
        try {           
            OKMNotification.getInstance().unsubscribe(null, "/okm:root/logo.png");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

getSubscriptors

Description:

MethodReturn valuesDescription

getSubscriptors(String token, String nodePath)

Set<String>

Retrieves a list of all the subscriptors of a node.

Example:

package com.openkm;

import com.openkm.api.OKMNotification;

public class Test {
    public static void main(String[] args) {
        try {           
            for (String subscriptor : OKMNotification.getInstance().getSubscriptors(null, "/okm:root/logo.png")) {
                System.out.println(subscriptor);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

notify

Description:

MethodReturn valuesDescription

notify(String token, String nodeId, List<String> users, List<String> mails, String message, boolean attachment)

void

Send a mail notification.

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

The parameter mails are a set of mails - 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.api.OKMNotification;

public class Test {
    public static void main(String[] args) {
        try {           
            List<String> users = new ArrayList<>();
            users.add("user1");
            List<String> mails = new ArrayList<>();
            String body = "Body of the message";
            OKMNotification.getInstance().notify(null, "/okm:root/logo.png", users, mails, body, false);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

proposedSubscription

Description:

MethodReturn valuesDescription

proposedSubscription(String token, String nodeId, List<String> users, String comment)

void

Propose a subscription by a mail notification.

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

The parameter comment is the content body of the mail.

Example:

package com.openkm;

import java.util.ArrayList;
import java.util.List;

import com.openkm.api.OKMNotification;

public class Test {
    public static void main(String[] args) {
        try {           
            List<String> users = new ArrayList<>();
            users.add("user1");
            String comment = "Body of the message";
            OKMNotification.getInstance().proposedSubscription(null, "/okm:root/logo.png", users, comment);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}