Author: shijh
Date: Thu Sep 3 09:07:24 2015 New Revision: 1700960 URL: http://svn.apache.org/r1700960 Log: OFBIZ-6596 The Solr redirection does not work in trunk demo. Commented out https scheme check. Let see whether it would work. Modified: ofbiz/trunk/specialpurpose/solr/src/org/ofbiz/solr/webapp/OFBizSolrRedirectServlet.java Modified: ofbiz/trunk/specialpurpose/solr/src/org/ofbiz/solr/webapp/OFBizSolrRedirectServlet.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/solr/src/org/ofbiz/solr/webapp/OFBizSolrRedirectServlet.java?rev=1700960&r1=1700959&r2=1700960&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/solr/src/org/ofbiz/solr/webapp/OFBizSolrRedirectServlet.java (original) +++ ofbiz/trunk/specialpurpose/solr/src/org/ofbiz/solr/webapp/OFBizSolrRedirectServlet.java Thu Sep 3 09:07:24 2015 @@ -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 ex } // 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; - } } |
Free forum by Nabble | Edit this page |