/*
 * #%L
 * carewebframework
 * %%
 * Copyright (C) 2008 - 2016 Regenstrief Institute, Inc.
 * %%
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 * This Source Code Form is also subject to the terms of the Health-Related
 * Additional Disclaimer of Warranty and Limitation of Liability available at
 *
 *      http://www.carewebframework.org/licensing/disclaimer.
 *
 * #L%
 */
package org.carewebframework.api.event;

import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.carewebframework.api.messaging.Recipient;

/**
 * Static utility class for the event operations.
 */
public class EventUtil {
    
    private static final Log log = LogFactory.getLog(EventUtil.class);
    
    public static final String STATUS_EVENT = "STATUS";
    
    /**
     * Returns the event manager for this application context.
     * 
     * @return IEventManager
     */
    public static IEventManager getEventManager() {
        return EventManager.getInstance();
    }
    
    /**
     * Fires a generic event of type STATUS with no status text. Used to signal subscribers to clear
     * any status information.
     */
    public static void status() {
        status(null);
    }
    
    /**
     * Fires a generic event of type STATUS to update any object that subscribes to it.
     * 
     * @param statusText Text associated with the status change.
     */
    public static void status(String statusText) {
        try {
            getEventManager().fireLocalEvent(STATUS_EVENT, statusText == null ? "" : statusText);
        } catch (Throwable e) {
            log.error(e);
        }
    }
    
    /**
     * Fires a ping request to specified or all recipients.
     * 
     * @param responseEvent Event to use for response.
     * @param filters Response filters (null for none).
     * @param recipients The list of ping recipients (or none for all recipients).
     */
    public static void ping(String responseEvent, List<PingFilter> filters, Recipient... recipients) {
        IEventManager eventManager = getEventManager();
        IGlobalEventDispatcher ged = ((ILocalEventDispatcher) eventManager).getGlobalEventDispatcher();
        
        if (ged != null) {
            ged.Ping(responseEvent, filters, recipients);
        }
    }
    
    /**
     * Returns the messaging channel name from the event name.
     * 
     * @param eventName The event name.
     * @return The channel name.
     */
    public static String getChannelName(String eventName) {
        return eventName == null ? null : "cwf-event-" + eventName.split("\\.", 2)[0];
    }
    
    /**
     * Enforce static class.
     */
    private EventUtil() {
    };
    
}

@@ -272,18 +272,17 @@
 se at%0A *
- 
 %0A
+
  *      
@@ -326,17 +326,16 @@
 E-2.0%0A *
- 
 %0A * Unle
@@ -650,17 +650,16 @@
 ense.%0A *
- 
 %0A * This
@@ -1248,24 +1248,86 @@
 lass);%0A    %0A
+    private static final String EVENT_PREFIX = %22cwf-event-%22;%0A%0A
     public s
@@ -1444,33 +1444,32 @@
  context.%0A     *
- 
 %0A     * @return 
@@ -1905,33 +1905,32 @@
 es to it.%0A     *
- 
 %0A     * @param s
@@ -2295,33 +2295,32 @@
 cipients.%0A     *
- 
 %0A     * @param r
@@ -2961,17 +2961,16 @@
 .%0A     *
- 
 %0A     * 
@@ -3145,28 +3145,28 @@
  null : 
-%22cwf-event-%22
+EVENT_PREFIX
  + event
@@ -3205,24 +3205,384 @@
    %0A    /**%0A
+     * Returns the event name from the channel name.%0A     *%0A     * @param channelName The channel name.%0A     * @return The event name.%0A     */%0A    public static String getEventName(String channelName) %7B%0A        int i = channelName.indexOf(EVENT_PREFIX);%0A        return i %3C 0 ? channelName : channelName.substring(i + EVENT_PREFIX.length());%0A    %7D%0A    %0A    /**%0A
      * Enfor
@@ -3636,14 +3636,13 @@
 ) %7B%0A
+
     %7D
-;
 %0A   

Add getEventName method.