Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (5.0/Cloud)

75028: Merged WAT2 (5.0/Cloud) to HEAD-BUG-FIX (5.0/Cloud)
      71712: Added BrowserEvent to the EventPublisher interface


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@75356 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Will Abson
2014-07-01 15:09:44 +00:00
parent 0ce189bbfa
commit 31426f765a
2 changed files with 31 additions and 0 deletions

View File

@@ -18,7 +18,9 @@
*/
package org.alfresco.repo.events;
import org.alfresco.events.types.BrowserEvent;
import org.alfresco.events.types.Event;
import org.springframework.extensions.webscripts.WebScriptRequest;
/**
* EventPublisher can be used to broadcast events.
@@ -36,6 +38,17 @@ public interface EventPublisher
*/
public void publishEvent(Event event);
/**
* A special type of Event that occurs in a web browser
* @see BrowserEvent
* @param req - WebScriptRequest
* @param siteId - optional site id
* @param component - page eg. "documentdetails"
* @param action - eg. "view"
* @param attributes - optional additional attributes as a json map eg. {"liked":"true"}
*/
public void publishBrowserEvent(WebScriptRequest req, String siteId, String component, String action, String attributes);
/**
* Publish the event using an EventPreparator
* @param prep EventPreparator

View File

@@ -18,9 +18,14 @@
*/
package org.alfresco.repo.events;
import org.alfresco.events.types.BrowserEvent;
import org.alfresco.events.types.Event;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.tenant.TenantUtil;
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.extensions.webscripts.WebScriptRequest;
/**
* An implementation of EventPublisher that does nothing.
@@ -50,4 +55,17 @@ public class NoOpEventPublisher implements EventPublisher {
}
}
@Override
public void publishBrowserEvent(final WebScriptRequest req, final String siteId, final String component, final String action, final String attributes)
{
publishEvent(new EventPreparator(){
@Override
public Event prepareEvent(String user, String networkId, String transactionId)
{
String agent = req.getHeader("user-agent");
return new BrowserEvent(user, networkId, transactionId, siteId, component, action, agent, attributes);
}
});
}
}