OKMNotification
Basics
Section titled “Basics”On most methods you’ll see parameter named “nodeId”. The value of this parameter can be a valid document, folder, mail or record UUID or path.
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”.
Methods
Section titled “Methods”subscribe
Section titled “subscribe”Description:
| Method | Return values | Description |
|---|---|---|
| subscribe(String token, String nodeId) | 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
Section titled “subscribe”Description:
| Method | Return values | Description |
|---|---|---|
| unsubscribe(String token, String nodeId) | 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
Section titled “getSubscriptors”Description:
| Method | Return values | Description |
|---|---|---|
| getSubscriptors(String token, String nodeId) | Set |
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
Section titled “notify”Description:
| Method | Return values | Description |
|---|---|---|
| notify(String token, String nodeId, List |
void | Send a mail notification. |
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
Section titled “proposedSubscription”Description:
| Method | Return values | Description |
|---|---|---|
| proposedSubscription(String token, String nodeId, List |
void | Propose a subscription by a mail notification. |
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(); } }}