public URL getReferer(HttpServletRequest request) { String refererStr = request.getHeader("referer"); if (refererStr == null) { return null; } URL referer = new URL(refererStr); // Remove feedback parameter referer.removeParameter("feedback"); return referer; }
public void handlerMove( HttpServletRequest request, HttpServletResponse response, HttpSession session, AdminService admin, ExtendedMap formItems, ExtendedMap parameters, User user, Document verticalDoc, boolean moveFolder) { ResourceKey sourceKey = ResourceKey.from(formItems.getString("sourceKey")); ResourceBase source = resourceService.getResource(sourceKey); if (source == null) { throw new IllegalArgumentException("Source (" + sourceKey + ") not found"); } ResourceKey destinationKey = ResourceKey.from(formItems.getString("destinationKey")); ResourceFolder destination = resourceService.getResourceFolder(destinationKey); if (destination == null) { throw new IllegalArgumentException("Destination (" + destinationKey + ") not found"); } ResourceKey newSourceKey = resourceService.moveResource(source, destination); if (moveFolder) { URL url = new URL(request.getHeader("referer")); MultiValueMap params = new MultiValueMap(); params.putAll(url.getParameterMap()); if (params.containsKey("reload")) { params.remove("reload"); } params.put("reload", "true"); if (params.containsKey("path")) { params.remove("path"); } params.put("path", resolvePathForNewFolder(sourceKey, newSourceKey)); redirectClientToAdminPath("adminpage", params, request, response); } else { redirectClientToReferer(request, response); } }