Class DefaultSimpleProxyEngine
- java.lang.Object
-
- de.hybris.platform.xyformsservices.proxy.orbeonservices.impl.DefaultSimpleProxyEngine
-
- All Implemented Interfaces:
ProxyEngine
public class DefaultSimpleProxyEngine extends java.lang.Object implements ProxyEngine
ProxyEngineimplementation for Orbeon.It uses a
CookieManagerto mantain orbeon's session.
-
-
Field Summary
Fields Modifier and Type Field Description protected CookieManagercookieManagerprotected static java.lang.StringDEFAULT_CHARSETprotected java.util.Set<java.lang.String>headersFromprotected java.util.Set<java.lang.String>headersToprotected static java.lang.StringLOCATION_HEADERprotected static java.lang.StringORBEON_PREFIXprotected static java.lang.StringORBEON_PREFIX_PLUS_SLASHprotected static java.lang.StringPOST_METHODprotected static java.lang.StringPUT_METHODprotected UrlRewriterurlRewriter
-
Constructor Summary
Constructors Constructor Description DefaultSimpleProxyEngine()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.net.HttpURLConnectionconnect(javax.servlet.http.HttpServletRequest request, java.lang.String url, java.lang.String method, java.util.Map<java.lang.String,java.lang.String> headers)Stablishes an HTTP connection with the given URL.java.lang.StringextractNamespace(javax.servlet.http.HttpServletRequest request)Extracts the namespace coming from client.protected ConfigurationServicegetConfigurationService()protected java.lang.StringgetHostPart(java.lang.String url)Gets the host part of an URL, including protocol, host, port with no trailing slash.protected java.lang.StringgetPrefixFromRequest(javax.servlet.http.HttpServletRequest request)Gets the prefix from the request URI address.protected booleanisServerError(int sc)True if the status code represents an error on the server sideprotected booleanisTextFile(java.lang.String contentType)Returns true if the given contentType refers to a text file.voidproxy(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String namespace, java.lang.String url, boolean forceGetMethod, java.util.Map<java.lang.String,java.lang.String> headers)Proxies contentprotected voidsendRequestHeaders(java.util.Set<java.lang.String> headers, javax.servlet.http.HttpServletRequest request, java.net.HttpURLConnection conn)Sends headers from the request to the remote server.protected voidsendResponseHeaders(java.util.Set<java.lang.String> headers, java.net.HttpURLConnection conn, javax.servlet.http.HttpServletResponse response)Get headers from remote connection and copies them back to the current response.voidsetConfigurationService(ConfigurationService configurationService)voidsetCookieManager(CookieManager cookieManager)voidsetHeadersFrom(java.util.List<java.lang.String> headersFrom)voidsetHeadersTo(java.util.List<java.lang.String> headersTo)voidsetUrlRewriter(UrlRewriter urlRewriter)
-
-
-
Field Detail
-
DEFAULT_CHARSET
protected static final java.lang.String DEFAULT_CHARSET
-
ORBEON_PREFIX
protected static final java.lang.String ORBEON_PREFIX
- See Also:
- Constant Field Values
-
ORBEON_PREFIX_PLUS_SLASH
protected static final java.lang.String ORBEON_PREFIX_PLUS_SLASH
- See Also:
- Constant Field Values
-
POST_METHOD
protected static final java.lang.String POST_METHOD
- See Also:
- Constant Field Values
-
PUT_METHOD
protected static final java.lang.String PUT_METHOD
- See Also:
- Constant Field Values
-
LOCATION_HEADER
protected static final java.lang.String LOCATION_HEADER
- See Also:
- Constant Field Values
-
cookieManager
protected CookieManager cookieManager
-
urlRewriter
protected UrlRewriter urlRewriter
-
headersTo
protected final java.util.Set<java.lang.String> headersTo
-
headersFrom
protected final java.util.Set<java.lang.String> headersFrom
-
-
Method Detail
-
extractNamespace
public java.lang.String extractNamespace(javax.servlet.http.HttpServletRequest request)
Extracts the namespace coming from client.- Specified by:
extractNamespacein interfaceProxyEngine- Parameters:
request-
-
proxy
public void proxy(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, java.lang.String namespace, java.lang.String url, boolean forceGetMethod, java.util.Map<java.lang.String,java.lang.String> headers) throws ProxyExceptionDescription copied from interface:ProxyEngineProxies content- Specified by:
proxyin interfaceProxyEngine- Parameters:
request- TheHttpServletRequestassociated to the callresponse- TheHttpServletResponseassociated to the callnamespace- Used for HTML element's id generationurl- The url to be calledforceGetMethod- Useful when proxying content, when false it uses the same method used in the original request.headers- Extra headers to be passed to the connection, useful for authentication headers.- Throws:
ProxyException
-
getHostPart
protected java.lang.String getHostPart(java.lang.String url)
Gets the host part of an URL, including protocol, host, port with no trailing slash.- Parameters:
url-
-
getPrefixFromRequest
protected java.lang.String getPrefixFromRequest(javax.servlet.http.HttpServletRequest request)
Gets the prefix from the request URI address.- Parameters:
request-
-
connect
protected java.net.HttpURLConnection connect(javax.servlet.http.HttpServletRequest request, java.lang.String url, java.lang.String method, java.util.Map<java.lang.String,java.lang.String> headers) throws java.net.URISyntaxException, java.net.MalformedURLException, java.io.IOException, org.apache.http.cookie.MalformedCookieExceptionStablishes an HTTP connection with the given URL.- Parameters:
request- Request to get headers from.url- HTTP Address to be connected.method- request method for orbeon- Throws:
java.net.URISyntaxException- If the URI is not well formedjava.net.MalformedURLException- If the URL is not well formedjava.io.IOException- If there is a connection problem with the remote server.org.apache.http.cookie.MalformedCookieException- If there is a problem when dealing with Cookies
-
isServerError
protected boolean isServerError(int sc)
True if the status code represents an error on the server side- Parameters:
sc-
-
isTextFile
protected boolean isTextFile(java.lang.String contentType)
Returns true if the given contentType refers to a text file.- Parameters:
contentType-
-
sendRequestHeaders
protected void sendRequestHeaders(java.util.Set<java.lang.String> headers, javax.servlet.http.HttpServletRequest request, java.net.HttpURLConnection conn)Sends headers from the request to the remote server.- Parameters:
headers- headers that should be sentrequest- Request to take header values from.conn- Remote server connection
-
sendResponseHeaders
protected void sendResponseHeaders(java.util.Set<java.lang.String> headers, java.net.HttpURLConnection conn, javax.servlet.http.HttpServletResponse response)Get headers from remote connection and copies them back to the current response.- Parameters:
headers- headers that should be copied backconn- Remote server connectionresponse- Response to copy header values to.
-
setCookieManager
public void setCookieManager(CookieManager cookieManager)
-
setUrlRewriter
public void setUrlRewriter(UrlRewriter urlRewriter)
-
setHeadersTo
public void setHeadersTo(java.util.List<java.lang.String> headersTo)
-
setHeadersFrom
public void setHeadersFrom(java.util.List<java.lang.String> headersFrom)
-
getConfigurationService
protected ConfigurationService getConfigurationService()
-
setConfigurationService
public void setConfigurationService(ConfigurationService configurationService)
-
-