From 0889e9138de3bcce6a6f2f45bcc510ed283a4e7a Mon Sep 17 00:00:00 2001 From: Shi Jinghai Date: Thu, 3 Sep 2015 09:07:24 +0000 Subject: [PATCH] OFBIZ-6596 The Solr redirection does not work in trunk demo. Commented out https scheme check. Let see whether it would work. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk/specialpurpose@1700960 13f79535-47bb-0310-9956-ffa450edef68 --- .../solr/webapp/OFBizSolrRedirectServlet.java | 85 +++++++------------ 1 file changed, 31 insertions(+), 54 deletions(-) diff --git a/solr/src/org/ofbiz/solr/webapp/OFBizSolrRedirectServlet.java b/solr/src/org/ofbiz/solr/webapp/OFBizSolrRedirectServlet.java index 26aa73917..aedf8f5e4 100644 --- a/solr/src/org/ofbiz/solr/webapp/OFBizSolrRedirectServlet.java +++ b/solr/src/org/ofbiz/solr/webapp/OFBizSolrRedirectServlet.java @@ -28,12 +28,9 @@ import javax.servlet.http.HttpSession; import org.apache.solr.servlet.RedirectServlet; import org.ofbiz.base.util.Debug; import org.ofbiz.base.util.UtilValidate; -import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericEntityException; import org.ofbiz.entity.GenericValue; import org.ofbiz.security.Security; -import org.ofbiz.security.SecurityConfigurationException; -import org.ofbiz.security.SecurityFactory; import org.ofbiz.webapp.OfbizUrlBuilder; import org.ofbiz.webapp.control.LoginWorker; import org.ofbiz.webapp.control.WebAppConfigurationException; @@ -99,57 +96,37 @@ public class OFBizSolrRedirectServlet extends RedirectServlet { } // check request schema - if (!request.getScheme().equals("https")) { - StringBuilder newURL = new StringBuilder(250); - // Build the scheme and host part - try { - OfbizUrlBuilder builder = OfbizUrlBuilder.from(request); - builder.buildHostPart(newURL, "", true); - } catch (GenericEntityException e) { - // If the entity engine is throwing exceptions, then there is no point in continuing. - Debug.logError(e, "Exception thrown while getting web site properties: ", module); - return false; - } catch (WebAppConfigurationException e) { - // If we can't read the controller.xml file, then there is no point in continuing. - Debug.logError(e, "Exception thrown while parsing controller.xml file: ", module); - return false; - } catch (IOException e) { - // If we can't write to StringBuilder, then there is no point in continuing. - Debug.logError(e, "Exception thrown while writing to StringBuilder: ", module); - return false; - } - newURL.append(request.getRequestURI()); - - // send the redirect - try { - response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY); - response.setHeader("Location", newURL.toString()); - response.setHeader("Connection", "close"); - } catch (IllegalStateException ise) { - throw new IOException(ise.getMessage(), ise); - } - return true; - } +// if (!request.getScheme().equals("https")) { +// StringBuilder newURL = new StringBuilder(250); +// // Build the scheme and host part +// try { +// OfbizUrlBuilder builder = OfbizUrlBuilder.from(request); +// builder.buildHostPart(newURL, "", true); +// } catch (GenericEntityException e) { +// // If the entity engine is throwing exceptions, then there is no point in continuing. +// Debug.logError(e, "Exception thrown while getting web site properties: ", module); +// return false; +// } catch (WebAppConfigurationException e) { +// // If we can't read the controller.xml file, then there is no point in continuing. +// Debug.logError(e, "Exception thrown while parsing controller.xml file: ", module); +// return false; +// } catch (IOException e) { +// // If we can't write to StringBuilder, then there is no point in continuing. +// Debug.logError(e, "Exception thrown while writing to StringBuilder: ", module); +// return false; +// } +// newURL.append(request.getRequestURI()); +// +// // send the redirect +// try { +// response.setStatus(HttpServletResponse.SC_MOVED_TEMPORARILY); +// response.setHeader("Location", newURL.toString()); +// response.setHeader("Connection", "close"); +// } catch (IllegalStateException ise) { +// throw new IOException(ise.getMessage(), ise); +// } +// return true; +// } return false; } - - protected Security getSecurity(HttpServletRequest request) { - Security security = (Security) request.getServletContext().getAttribute("security"); - if (security == null) { - Delegator delegator = (Delegator) request.getServletContext().getAttribute("delegator"); - - if (delegator != null) { - try { - security = SecurityFactory.getInstance(delegator); - } catch (SecurityConfigurationException e) { - Debug.logError(e, "Unable to obtain an instance of the security object.", module); - } - } - request.getServletContext().setAttribute("security", security); - if (security == null) { - Debug.logError("An invalid (null) Security object has been set in the servlet context.", module); - } - } - return security; - } }