Package org.dspace.usage

Examples of org.dspace.usage.UsageEvent


       
        //new UsageEvent().fire(request, context, AbstractUsageEvent.VIEW,
    //    Constants.BITSTREAM, bitstream.getID());

        new DSpace().getEventService().fireEvent(
            new UsageEvent(
                UsageEvent.Action.VIEW,
                request,
                context,
                bitstream));
       
View Full Code Here


        if (dso.getType() == Constants.ITEM)
        {
            Item item = (Item) dso;

            new DSpace().getEventService().fireEvent(
                new UsageEvent(
                    UsageEvent.Action.VIEW,
                    request,
                    context,
                    dso));
           
            // Only use last-modified if this is an anonymous access
            // - caching content that may be generated under authorisation
            //   is a security problem
            if (context.getCurrentUser() == null)
            {
                response.setDateHeader("Last-Modified", item
                        .getLastModified().getTime());

                // Check for if-modified-since header
                long modSince = request.getDateHeader("If-Modified-Since");

                if (modSince != -1 && item.getLastModified().getTime() < modSince)
                {
                    // Item has not been modified since requested date,
                    // hence bitstream has not; return 304
                    response.setStatus(HttpServletResponse.SC_NOT_MODIFIED);
                }
                else
                {
                    // Display the item page
                    displayItem(context, request, response, item, handle);
                }
            }
            else
            {
                // Display the item page
                displayItem(context, request, response, item, handle);
            }
        }
        else if (dso.getType() == Constants.COLLECTION)
        {
            Collection c = (Collection) dso;

            new DSpace().getEventService().fireEvent(
                new UsageEvent(
                    UsageEvent.Action.VIEW,
                    request,
                    context,
                    dso));
           
            //UsageEvent ue = new UsageEvent();
            //ue.fire(request, context, AbstractUsageEvent.VIEW,
            //        Constants.COLLECTION, dso.getID());

            // Store collection location in request
            request.setAttribute("dspace.collection", c);

            /*
             * Find the "parent" community the collection, mainly for
             * "breadcrumbs" FIXME: At the moment, just grab the first community
             * the collection is in. This should probably be more context
             * sensitive when we have multiple inclusion.
             */
            Community[] parents = c.getCommunities();
            request.setAttribute("dspace.community", parents[0]);

            /*
             * Find all the "parent" communities for the collection for
             * "breadcrumbs"
             */
            request.setAttribute("dspace.communities", getParents(parents[0],
                    true));

            // home page, or forward to another page?
            if ((extraPathInfo == null) || (extraPathInfo.equals("/")))
            {
                collectionHome(context, request, response, parents[0], c);
            }
            else
            {
                // Forward to another servlet
                request.getRequestDispatcher(extraPathInfo).forward(request,
                        response);
            }
        }
        else if (dso.getType() == Constants.COMMUNITY)
        {
            Community c = (Community) dso;

            new DSpace().getEventService().fireEvent(
                new UsageEvent(
                    UsageEvent.Action.VIEW,
                    request,
                    context,
                    dso));
           
View Full Code Here

        {
            log.info(LogManager.getHeader(context, "view_bitstream",
                    "bitstream_id=" + bitstream.getID()));

            new DSpace().getEventService().fireEvent(
                new UsageEvent(
                    UsageEvent.Action.VIEW,
                    request,
                    context,
                    bitstream));
           
View Full Code Here

            return;
        }

        if ((user_ip == null) || (user_ip.length() == 0))
        {
            new DSpace().getEventService().fireEvent(new UsageEvent(action, request, context, dspaceObject));
        }
        else
        {
            new DSpace().getEventService().fireEvent(
                    new UsageEvent(action, user_ip, user_agent, xforwarderfor, context, dspaceObject));
        }

        log.debug("fired event");
    }
View Full Code Here

            }
           
            // Log that the bitstream has been viewed, this is non-cached and the complexity
            // of adding it to the sitemap for every possible bitstream uri is not very tractable
            new DSpace().getEventService().fireEvent(
                                new UsageEvent(
                                                UsageEvent.Action.VIEW,
                                                ObjectModelHelper.getRequest(objectModel),
                                                ContextUtil.obtainContext(ObjectModelHelper.getRequest(objectModel)),
                                                bitstream));
           
View Full Code Here

                analyticsKey = new DSpace().getConfigurationService().getProperty("xmlui.google.analytics.key");
            }

            if (analyticsKey != null ) {
                try {
                    UsageEvent ue = (UsageEvent)event;
                    if(UsageEvent.Action.VIEW == ue.getAction() && (Constants.BITSTREAM == ue.getObject().getType())) {
                        bitstreamDownload(ue);
                    }
                }
                catch(Exception e)
                {
View Full Code Here

    if(event instanceof UsageEvent)
    {
      log.debug("Usage event received " + ((UsageEvent)event).getName());
      try{
          UsageEvent ue = (UsageEvent)event;
     
          EPerson currentUser = ue.getContext() == null ? null : ue.getContext().getCurrentUser();

                if(UsageEvent.Action.VIEW == ue.getAction()){
                  if(ue.getRequest()!=null){
                    SolrLogger.postView(ue.getObject(), ue.getRequest(), currentUser);
                  } else {
                    SolrLogger.postView(ue.getObject(), ue.getIp(), ue.getUserAgent(), ue.getXforwarderfor(), currentUser);
                  }
                }else
                if(UsageEvent.Action.SEARCH == ue.getAction()){
                    UsageSearchEvent usageSearchEvent = (UsageSearchEvent) ue;
                    //Only log if the user has already filled in a query !
                    if(!CollectionUtils.isEmpty(((UsageSearchEvent) ue).getQueries())){
                        SolrLogger.postSearch(ue.getObject(), ue.getRequest(), currentUser,
                                usageSearchEvent.getQueries(), usageSearchEvent.getRpp(), usageSearchEvent.getSortBy(),
                                usageSearchEvent.getSortOrder(), usageSearchEvent.getPage(), usageSearchEvent.getScope());
                    }
                }else
                if(UsageEvent.Action.WORKFLOW == ue.getAction()){
                    UsageWorkflowEvent usageWorkflowEvent = (UsageWorkflowEvent) ue;

                    SolrLogger.postWorkflow(usageWorkflowEvent);
                }
View Full Code Here

        if(event instanceof UsageEvent && (((UsageEvent) event).getAction() == UsageEvent.Action.VIEW))
        {
            try{

                UsageEvent ue = (UsageEvent) event;

                EPerson currentUser = ue.getContext() == null ? null : ue.getContext().getCurrentUser();

                ElasticSearchLogger.getInstance().post(ue.getObject(), ue.getRequest(), currentUser);
                log.info("Successfully logged " + ue.getObject().getTypeText() + "_" + ue.getObject().getID() + " " + ue.getObject().getName());
            }
            catch(Exception e)
            {
                log.error("General Exception: " + e.getMessage());
            }
View Full Code Here

        }

        try {
         
      new DSpace().getEventService().fireEvent(
          new UsageEvent(
              UsageEvent.Action.VIEW,
              (HttpServletRequest)request,
              ContextUtil.obtainContext((HttpServletRequest)request),
              dso));
     
View Full Code Here

       
        //new UsageEvent().fire(request, context, AbstractUsageEvent.VIEW,
    //    Constants.BITSTREAM, bitstream.getID());

        new DSpace().getEventService().fireEvent(
            new UsageEvent(
                UsageEvent.Action.VIEW,
                request,
                context,
                bitstream));
       
View Full Code Here

TOP

Related Classes of org.dspace.usage.UsageEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.