GeneralUtils
GeneralUtils is a Spring bean that provides methods for sending in-application UI notifications to users.
Methods
Section titled “Methods”uiNotify (current user)
Section titled “uiNotify (current user)”Description:
| Method | Return values | Description |
|---|---|---|
| uiNotify(String msg) | void | Sends an in-application UI notification to the currently authenticated user. |
- msg: The notification message text.
Example:
package com.openkm;
import com.openkm.util.ContextWrapper;import com.openkm.util.GeneralUtils;
public class Test {
public static void main(String[] args) { try { GeneralUtils generalUtils = ContextWrapper.getContext().getBean(GeneralUtils.class); generalUtils.uiNotify("Your export is ready."); } catch (Exception e) { e.printStackTrace(); } }}uiNotify (set of users)
Section titled “uiNotify (set of users)”Description:
| Method | Return values | Description |
|---|---|---|
| uiNotify(String msg, Set |
void | Sends an in-application UI notification to a specific set of users. |
- msg: The notification message text.
- users: The set of usernames to notify.
Example:
package com.openkm;
import com.openkm.util.ContextWrapper;import com.openkm.util.GeneralUtils;
import java.util.HashSet;import java.util.Set;
public class Test {
public static void main(String[] args) { try { GeneralUtils generalUtils = ContextWrapper.getContext().getBean(GeneralUtils.class); Set<String> recipients = new HashSet<>(); recipients.add("jsmith"); recipients.add("mjones"); generalUtils.uiNotify("Scheduled maintenance in 10 minutes.", recipients); } catch (Exception e) { e.printStackTrace(); } }}uiNotifyAll
Section titled “uiNotifyAll”Description:
| Method | Return values | Description |
|---|---|---|
| uiNotifyAll(String msg) | void | Sends an in-application UI notification to all active users in the current tenant. |
- msg: The notification message text.
Example:
package com.openkm;
import com.openkm.util.ContextWrapper;import com.openkm.util.GeneralUtils;
public class Test {
public static void main(String[] args) { try { GeneralUtils generalUtils = ContextWrapper.getContext().getBean(GeneralUtils.class); generalUtils.uiNotifyAll("System will restart in 5 minutes. Please save your work."); } catch (Exception e) { e.printStackTrace(); } }}