private void writeStats( org.dspace.core.Context context, Integer bitstream_id, String user_ip, String user_agent, String xforwarderfor, HttpHeaders headers, HttpServletRequest request) { try { DSpaceObject bitstream = DSpaceObject.find(context, Constants.BITSTREAM, bitstream_id); if (user_ip == null || user_ip.length() == 0) { new DSpace() .getEventService() .fireEvent(new UsageEvent(UsageEvent.Action.VIEW, request, context, bitstream)); } else { new DSpace() .getEventService() .fireEvent( new UsageEvent( UsageEvent.Action.VIEW, user_ip, user_agent, xforwarderfor, context, bitstream)); } log.debug("fired event"); } catch (SQLException ex) { log.error("SQL exception can't write usageEvent \n" + ex); } }
/** * Return the specific DSpaceObject. Could be a community, collection or item. * * @param context DSpace context * @param type DSpace Object Type * @param ref ID of the object * @return the DSpaceObject if exists or null */ private DSpaceObject getDSpaceObject(Context context, int type, int ref) { DSpaceObject obj = null; try { obj = DSpaceObject.find(context, type, ref); } catch (SQLException ex) { Logger.getLogger(ActualContentManagement.class.getName()).log(Level.SEVERE, null, ex); } return obj; }