diff --git a/dspace-api/src/main/java/org/dspace/event/Consumer.java b/dspace-api/src/main/java/org/dspace/event/Consumer.java deleted file mode 100644 index 2e628180aa..0000000000 --- a/dspace-api/src/main/java/org/dspace/event/Consumer.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree and available online at - * - * http://www.dspace.org/license/ - */ -package org.dspace.event; - -import org.dspace.core.Context; - -/** - * Interface for content event consumers. Note that the consumer cannot tell if - * it is invoked synchronously or asynchronously; the consumer interface and - * sequence of calls is the same for both. Asynchronous consumers may see more - * consume() calls between the start and end of the event stream, if they are - * invoked asynchronously, once in a long time period, rather than synchronously - * after every Context.commit(). - * - * @version $Revision$ - */ -public interface Consumer -{ - /** - * Initialize - allocate any resources required to operate. This may include - * initializing any pooled JMS resources. Called ONCE when created by the - * dispatcher pool. This should be used to set up expensive resources that - * will remain for the lifetime of the consumer. - */ - public void initialize() throws Exception; - - /** - * Consume an event; events may get filtered at the dispatcher level, hiding - * it from the consumer. This behavior is based on the dispatcher/consumer - * configuration. Should include logic to initialize any resources required - * for a batch of events. - * - * @param ctx - * the execution context object - * - * @param event - * the content event - */ - public void consume(Context ctx, Event event) throws Exception; - - /** - * Signal that there are no more events queued in this event stream and - * event processing for the preceding consume calls should be finished up. - */ - public void end(Context ctx) throws Exception; - - /** - * Finish - free any allocated resources. Called when consumer (via it's - * parent dispatcher) is going to be destroyed by the dispatcher pool. - */ - public void finish(Context ctx) throws Exception; - -} diff --git a/dspace-api/src/main/java/org/dspace/usage/AbstractUsageEventListener.java b/dspace-api/src/main/java/org/dspace/usage/AbstractUsageEventListener.java deleted file mode 100644 index 65c1494c6b..0000000000 --- a/dspace-api/src/main/java/org/dspace/usage/AbstractUsageEventListener.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree and available online at - * - * http://www.dspace.org/license/ - */ -package org.dspace.usage; - -import org.dspace.services.EventService; -import org.dspace.services.model.EventListener; - -/** - * AbstractUsageEventListener is used as the base class for listening events running - * in the EventService. - * - * @author Mark Diggory (mdiggory at atmire.com) - * @version $Revision: $ - */ -public abstract class AbstractUsageEventListener implements EventListener { - - public AbstractUsageEventListener() { - super(); - } - - /** - * Empty String[] flags to have Listener - * consume any event name prefixes. - */ - public String[] getEventNamePrefixes() { - return new String[0]; - } - - /** - * Currently consumes events generated for - * all resources. - */ - public String getResourcePrefix() { - return null; - } - - public void setEventService(EventService service) { - if(service != null) - { - service.registerEventListener(this); - } - else - { - throw new IllegalStateException("EventService handed to Listener cannot be null"); - } - - } - -} \ No newline at end of file diff --git a/dspace-api/src/main/java/org/dspace/usage/UsageEvent.java b/dspace-api/src/main/java/org/dspace/usage/UsageEvent.java deleted file mode 100644 index d25df53c0c..0000000000 --- a/dspace-api/src/main/java/org/dspace/usage/UsageEvent.java +++ /dev/null @@ -1,157 +0,0 @@ -/** - * The contents of this file are subject to the license and copyright - * detailed in the LICENSE and NOTICE files at the root of the source - * tree and available online at - * - * http://www.dspace.org/license/ - */ -package org.dspace.usage; - -import javax.servlet.http.HttpServletRequest; - -import org.dspace.content.DSpaceObject; -import org.dspace.core.Constants; -import org.dspace.core.Context; -import org.dspace.services.model.Event; - -/** - * - * @author Mark Diggory (mdiggory at atmire.com) - * - */ -public class UsageEvent extends Event { - - public static enum Action { - VIEW ("view"), - CREATE ("create"), - UPDATE ("update"), - DELETE ("delete"), - ADD ("add"), - REMOVE ("remove"), - BROWSE ("browse"), - SEARCH ("search"), - LOGIN ("login"), - SUBSCRIBE ("subscribe"), - UNSUBSCRIBE ("unsubscribe"), - WITHDRAW ("withdraw"), - REINSTATE ("reinstate"); - - private final String text; - - Action(String text) { - this.text = text; - } - String text() { return text; } - } - - /** - * - */ - private static final long serialVersionUID = 1L; - - private transient HttpServletRequest request; - - private transient Context context; - - private transient DSpaceObject object; - - private Action action; - - private static String checkParams(Action action, HttpServletRequest request, Context context, DSpaceObject object) - { - if(action == null) - { - throw new IllegalStateException("action cannot be null"); - } - - if(request == null) - { - throw new IllegalStateException("request cannot be null"); - } - - - if(context == null) - { - throw new IllegalStateException("context cannot be null"); - } - - if(object == null) - { - throw new IllegalStateException("object cannot be null"); - } - - try - { - String objText = Constants.typeText[object.getType()].toLowerCase(); - return objText + ":" + action.text(); - }catch(Exception e) - { - - } - return ""; - - } - - public UsageEvent(Action action, HttpServletRequest request, Context context, DSpaceObject object) - { - - super(checkParams(action, request, context, object)); - - this.action = action; - - this.setResourceReference(object != null ? Constants.typeText[object.getType()].toLowerCase() + ":" + object.getID() : null); - - switch(action) - { - case CREATE: - case UPDATE: - case DELETE: - case WITHDRAW: - case REINSTATE: - case ADD: - case REMOVE: - this.setModify(true); - break; - default : - this.setModify(false); - } - - if(context != null && context.getCurrentUser() != null) - { - this.setUserId( - String.valueOf(context.getCurrentUser().getID())); - } - this.request = request; - this.context = context; - this.object = object; - } - - public HttpServletRequest getRequest() { - return request; - } - - public void setRequest(HttpServletRequest request) { - this.request = request; - } - - public Context getContext() { - return context; - } - - public void setContext(Context context) { - this.context = context; - } - - public DSpaceObject getObject() { - return object; - } - - public void setObject(DSpaceObject object) { - this.object = object; - } - - public Action getAction() { - return this.action; - } - -}