@Test public void testGetBaseParameters() throws UnsupportedEncodingException { context.turnOffAuthorisationSystem(); Community community = CommunityBuilder.createCommunity(context).build(); Collection collection = CollectionBuilder.createCollection(context, community).build(); Item item = ItemBuilder.createItem(context, collection).build(); String encodedHandle = URLEncoder.encode(item.getHandle(), CharEncoding.UTF_8); context.restoreAuthSystemState(); ExportEventProcessor exportEventProcessor = new ItemEventProcessor(context, request, item); when(request.getRemoteAddr()).thenReturn("test-client-ip"); when(request.getHeader("USER-AGENT")).thenReturn("test-user-agent"); when(request.getHeader("referer")).thenReturn("test-referer"); String result = exportEventProcessor.getBaseParameters(item); String expected = "url_ver=Z39.88-2004&req_id=test-client-ip&req_dat=test-user-agent&rft.artnum=" + "oai%3Alocalhost%3A" + encodedHandle + "&rfr_dat=test-referer&rfr_id=localhost&url_tim="; assertThat(result, startsWith(expected)); }
protected String getBaseParameters(Item item) throws UnsupportedEncodingException { String clientIP = request.getRemoteAddr(); if (configurationService.getBooleanProperty("useProxies", false) && request .getHeader("X-Forwarded-For") != null) { for (String xfip : request.getHeader("X-Forwarded-For").split(",")) { if (!request.getHeader("X-Forwarded-For").contains(clientIP)) { clientIP = xfip.trim(); } } } String clientUA = StringUtils.defaultIfBlank(request.getHeader("USER-AGENT"), ""); String referer = StringUtils.defaultIfBlank(request.getHeader("referer"), ""); StringBuilder data = new StringBuilder(); data.append(URLEncoder.encode("url_ver", UTF_8) + "=" + URLEncoder.encode(configurationService.getProperty("irus.statistics.tracker.urlversion"), UTF_8)); data.append("&").append(URLEncoder.encode("req_id", UTF_8)).append("=") .append(URLEncoder.encode(clientIP, UTF_8)); data.append("&").append(URLEncoder.encode("req_dat", UTF_8)).append("=") .append(URLEncoder.encode(clientUA, UTF_8)); String hostName = Utils.getHostName(configurationService.getProperty("dspace.ui.url")); data.append("&").append(URLEncoder.encode("rft.artnum", UTF_8)).append("="). append(URLEncoder.encode("oai:" + hostName + ":" + item .getHandle(), UTF_8)); data.append("&").append(URLEncoder.encode("rfr_dat", UTF_8)).append("=") .append(URLEncoder.encode(referer, UTF_8)); data.append("&").append(URLEncoder.encode("rfr_id", UTF_8)).append("=") .append(URLEncoder.encode(hostName, UTF_8)); data.append("&").append(URLEncoder.encode("url_tim", UTF_8)).append("=") .append(URLEncoder.encode(getCurrentDateString(), UTF_8)); return data.toString(); }
ExportEventProcessor { protected String getBaseParameters(Item item) throws UnsupportedEncodingException { String clientIP = request.getRemoteAddr(); if (configurationService.getBooleanProperty("useProxies", false) && request .getHeader("X-Forwarded-For") != null) { for (String xfip : request.getHeader("X-Forwarded-For").split(",")) { if (!request.getHeader("X-Forwarded-For").contains(clientIP)) { clientIP = xfip.trim(); } } } String clientUA = StringUtils.defaultIfBlank(request.getHeader("USER-AGENT"), ""); String referer = StringUtils.defaultIfBlank(request.getHeader("referer"), ""); StringBuilder data = new StringBuilder(); data.append(URLEncoder.encode("url_ver", UTF_8) + "=" + URLEncoder.encode(configurationService.getProperty("irus.statistics.tracker.urlversion"), UTF_8)); data.append("&").append(URLEncoder.encode("req_id", UTF_8)).append("=") .append(URLEncoder.encode(clientIP, UTF_8)); data.append("&").append(URLEncoder.encode("req_dat", UTF_8)).append("=") .append(URLEncoder.encode(clientUA, UTF_8)); String hostName = Utils.getHostName(configurationService.getProperty("dspace.ui.url")); data.append("&").append(URLEncoder.encode("rft.artnum", UTF_8)).append("="). append(URLEncoder.encode("oai:" + hostName + ":" + item .getHandle(), UTF_8)); data.append("&").append(URLEncoder.encode("rfr_dat", UTF_8)).append("=") .append(URLEncoder.encode(referer, UTF_8)); data.append("&").append(URLEncoder.encode("rfr_id", UTF_8)).append("=") .append(URLEncoder.encode(hostName, UTF_8)); data.append("&").append(URLEncoder.encode("url_tim", UTF_8)).append("=") .append(URLEncoder.encode(getCurrentDateString(), UTF_8)); return data.toString(); } }
ExportEventProcessor { protected String getBaseParameters(Item item) throws UnsupportedEncodingException { String clientIP = request.getRemoteAddr(); if (configurationService.getBooleanProperty("useProxies", false) && request .getHeader("X-Forwarded-For") != null) { for (String xfip : request.getHeader("X-Forwarded-For").split(",")) { if (!request.getHeader("X-Forwarded-For").contains(clientIP)) { clientIP = xfip.trim(); } } } String clientUA = StringUtils.defaultIfBlank(request.getHeader("USER-AGENT"), ""); String referer = StringUtils.defaultIfBlank(request.getHeader("referer"), ""); StringBuilder data = new StringBuilder(); data.append(URLEncoder.encode("url_ver", UTF_8) + "=" + URLEncoder.encode(configurationService.getProperty("irus.statistics.tracker.urlversion"), UTF_8)); data.append("&").append(URLEncoder.encode("req_id", UTF_8)).append("=") .append(URLEncoder.encode(clientIP, UTF_8)); data.append("&").append(URLEncoder.encode("req_dat", UTF_8)).append("=") .append(URLEncoder.encode(clientUA, UTF_8)); String hostName = Utils.getHostName(configurationService.getProperty("dspace.ui.url")); data.append("&").append(URLEncoder.encode("rft.artnum", UTF_8)).append("="). append(URLEncoder.encode("oai:" + hostName + ":" + item .getHandle(), UTF_8)); data.append("&").append(URLEncoder.encode("rfr_dat", UTF_8)).append("=") .append(URLEncoder.encode(referer, UTF_8)); data.append("&").append(URLEncoder.encode("rfr_id", UTF_8)).append("=") .append(URLEncoder.encode(hostName, UTF_8)); data.append("&").append(URLEncoder.encode("url_tim", UTF_8)).append("=") .append(URLEncoder.encode(getCurrentDateString(), UTF_8)); return data.toString(); } ExportEventProcessor(Context context, HttpServletRequest request); }
ExportEventProcessor { protected String getBaseParameters(Item item) throws UnsupportedEncodingException { String clientIP = request.getRemoteAddr(); if (configurationService.getBooleanProperty("useProxies", false) && request .getHeader("X-Forwarded-For") != null) { for (String xfip : request.getHeader("X-Forwarded-For").split(",")) { if (!request.getHeader("X-Forwarded-For").contains(clientIP)) { clientIP = xfip.trim(); } } } String clientUA = StringUtils.defaultIfBlank(request.getHeader("USER-AGENT"), ""); String referer = StringUtils.defaultIfBlank(request.getHeader("referer"), ""); StringBuilder data = new StringBuilder(); data.append(URLEncoder.encode("url_ver", UTF_8) + "=" + URLEncoder.encode(configurationService.getProperty("irus.statistics.tracker.urlversion"), UTF_8)); data.append("&").append(URLEncoder.encode("req_id", UTF_8)).append("=") .append(URLEncoder.encode(clientIP, UTF_8)); data.append("&").append(URLEncoder.encode("req_dat", UTF_8)).append("=") .append(URLEncoder.encode(clientUA, UTF_8)); String hostName = Utils.getHostName(configurationService.getProperty("dspace.ui.url")); data.append("&").append(URLEncoder.encode("rft.artnum", UTF_8)).append("="). append(URLEncoder.encode("oai:" + hostName + ":" + item .getHandle(), UTF_8)); data.append("&").append(URLEncoder.encode("rfr_dat", UTF_8)).append("=") .append(URLEncoder.encode(referer, UTF_8)); data.append("&").append(URLEncoder.encode("rfr_id", UTF_8)).append("=") .append(URLEncoder.encode(hostName, UTF_8)); data.append("&").append(URLEncoder.encode("url_tim", UTF_8)).append("=") .append(URLEncoder.encode(getCurrentDateString(), UTF_8)); return data.toString(); } ExportEventProcessor(Context context, HttpServletRequest request); abstract void processEvent(); }
ExportEventProcessor { protected String getBaseParameters(Item item) throws UnsupportedEncodingException { String clientIP = request.getRemoteAddr(); if (configurationService.getBooleanProperty("useProxies", false) && request .getHeader("X-Forwarded-For") != null) { for (String xfip : request.getHeader("X-Forwarded-For").split(",")) { if (!request.getHeader("X-Forwarded-For").contains(clientIP)) { clientIP = xfip.trim(); } } } String clientUA = StringUtils.defaultIfBlank(request.getHeader("USER-AGENT"), ""); String referer = StringUtils.defaultIfBlank(request.getHeader("referer"), ""); StringBuilder data = new StringBuilder(); data.append(URLEncoder.encode("url_ver", UTF_8) + "=" + URLEncoder.encode(configurationService.getProperty("irus.statistics.tracker.urlversion"), UTF_8)); data.append("&").append(URLEncoder.encode("req_id", UTF_8)).append("=") .append(URLEncoder.encode(clientIP, UTF_8)); data.append("&").append(URLEncoder.encode("req_dat", UTF_8)).append("=") .append(URLEncoder.encode(clientUA, UTF_8)); String hostName = Utils.getHostName(configurationService.getProperty("dspace.ui.url")); data.append("&").append(URLEncoder.encode("rft.artnum", UTF_8)).append("="). append(URLEncoder.encode("oai:" + hostName + ":" + item .getHandle(), UTF_8)); data.append("&").append(URLEncoder.encode("rfr_dat", UTF_8)).append("=") .append(URLEncoder.encode(referer, UTF_8)); data.append("&").append(URLEncoder.encode("rfr_id", UTF_8)).append("=") .append(URLEncoder.encode(hostName, UTF_8)); data.append("&").append(URLEncoder.encode("url_tim", UTF_8)).append("=") .append(URLEncoder.encode(getCurrentDateString(), UTF_8)); return data.toString(); } ExportEventProcessor(Context context, HttpServletRequest request); abstract void processEvent();  }