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
This commit is contained in:
Shi Jinghai
2015-09-03 09:07:24 +00:00
parent 65316f0723
commit 0889e9138d
@@ -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;
}
}