Package org.ametys.site
Class BackOfficeRequestHelper
- java.lang.Object
-
- org.ametys.site.BackOfficeRequestHelper
-
public final class BackOfficeRequestHelper extends Object
Helper class that builds the request the front-office makes to the back-office to query a page or a resource.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
BackOfficeRequestHelper.HttpLock
(package private) static class
BackOfficeRequestHelper.HttpMkcol
(package private) static class
BackOfficeRequestHelper.HttpPropfind
(package private) static class
BackOfficeRequestHelper.HttpUnLock
-
Field Summary
Fields Modifier and Type Field Description private static Pattern
__AUTHORIZED_HEADERS
private static Set<String>
__FILTERED_REQUEST_PARAMETERS
-
Constructor Summary
Constructors Modifier Constructor Description private
BackOfficeRequestHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
_addMultipartEntityToBuilder(org.apache.http.entity.mime.MultipartEntityBuilder builder, String paramName, Object value)
private static void
_addRequestHeaders(Request request, HttpUriRequest boRequest, BackOfficeRequestProxyExtensionPoint requestProxyExtensionPoint)
Add headers indicating this is a request from the front-office to the back-office, specifying the user if applicable.private static void
_copyCookieHeaders(Request request, HttpUriRequest boRequest)
Copy cookie headers that were sent by the client into the request that will be sent to the back-office.private static String
_getContextQueryPart(SiteUrl url, String baseServerPath)
private static String
_getEditionQueryPart(Request request)
private static HttpUriRequest
_getGetHeadOptionsOrUnlockRequest(Request request, String method, SiteUrl url, String baseServerPath, String baseUrl)
private static org.apache.http.entity.mime.MultipartEntityBuilder
_getMultipartEntityBuilder(Request request)
Get the front-office request's parameters as an HttpClient MultipartEntity, to be added to a POST back-office request.private static String
_getParameters(Request request)
Get the front-office request's parameters as a String, to be added to a GET back-office request.private static HttpUriRequest
_getPostRequest(Map objectModel, Request request, SiteUrl url, String baseServerPath, String baseUrl)
private static HttpUriRequest
_getPutLockPropfindOrMkcolRequest(Map objectModel, Request request, String method, SiteUrl url, String baseServerPath, String baseUrl)
private static HttpUriRequest
_getRequest(Map objectModel, Request request, String method, SiteUrl url, String baseServerPath, String baseUrl)
static CloseableHttpClient
getHttpClient()
Build a HttpClient object parametrizedstatic HttpUriRequest
getRequest(Map objectModel, String page, BackOfficeRequestProxyExtensionPoint requestProxyExtensionPoint)
Build a HttpClient request object that will be sent to the back-office to query the page.
-
-
-
Field Detail
-
__AUTHORIZED_HEADERS
private static final Pattern __AUTHORIZED_HEADERS
-
__FILTERED_REQUEST_PARAMETERS
private static final Set<String> __FILTERED_REQUEST_PARAMETERS
-
-
Constructor Detail
-
BackOfficeRequestHelper
private BackOfficeRequestHelper()
-
-
Method Detail
-
getHttpClient
public static CloseableHttpClient getHttpClient()
Build a HttpClient object parametrized- Returns:
- The httpclient object
-
getRequest
public static HttpUriRequest getRequest(Map objectModel, String page, BackOfficeRequestProxyExtensionPoint requestProxyExtensionPoint) throws IOException
Build a HttpClient request object that will be sent to the back-office to query the page.- Parameters:
objectModel
- the current object model.page
- the wanted page path.requestProxyExtensionPoint
- The extension point for adding request headers in BO request- Returns:
- the HttpClient request, to be sent to the back-office.
- Throws:
IOException
- if an error occurs building the request.
-
_getRequest
private static HttpUriRequest _getRequest(Map objectModel, Request request, String method, SiteUrl url, String baseServerPath, String baseUrl) throws IOException, UnsupportedEncodingException
-
_getPostRequest
private static HttpUriRequest _getPostRequest(Map objectModel, Request request, SiteUrl url, String baseServerPath, String baseUrl) throws IOException, UnsupportedEncodingException
-
_getPutLockPropfindOrMkcolRequest
private static HttpUriRequest _getPutLockPropfindOrMkcolRequest(Map objectModel, Request request, String method, SiteUrl url, String baseServerPath, String baseUrl) throws IOException
- Throws:
IOException
-
_getGetHeadOptionsOrUnlockRequest
private static HttpUriRequest _getGetHeadOptionsOrUnlockRequest(Request request, String method, SiteUrl url, String baseServerPath, String baseUrl)
-
_getEditionQueryPart
private static String _getEditionQueryPart(Request request)
-
_getContextQueryPart
private static String _getContextQueryPart(SiteUrl url, String baseServerPath)
-
_getMultipartEntityBuilder
private static org.apache.http.entity.mime.MultipartEntityBuilder _getMultipartEntityBuilder(Request request) throws IOException
Get the front-office request's parameters as an HttpClient MultipartEntity, to be added to a POST back-office request.- Parameters:
request
- the front-office request.- Returns:
- the parameters encoded in a multipart entity.
- Throws:
IOException
- if an error occurs extracting the parameters or building the entity.
-
_addMultipartEntityToBuilder
private static void _addMultipartEntityToBuilder(org.apache.http.entity.mime.MultipartEntityBuilder builder, String paramName, Object value) throws IOException
- Throws:
IOException
-
_getParameters
private static String _getParameters(Request request)
Get the front-office request's parameters as a String, to be added to a GET back-office request.- Parameters:
request
- the front-office request.- Returns:
- the parameters as a String.
-
_addRequestHeaders
private static void _addRequestHeaders(Request request, HttpUriRequest boRequest, BackOfficeRequestProxyExtensionPoint requestProxyExtensionPoint)
Add headers indicating this is a request from the front-office to the back-office, specifying the user if applicable.- Parameters:
request
- the front-office request.boRequest
- the request object to be sent to the back-office.requestProxyExtensionPoint
- The extension point for adding request headers in BO request
-
_copyCookieHeaders
private static void _copyCookieHeaders(Request request, HttpUriRequest boRequest)
Copy cookie headers that were sent by the client into the request that will be sent to the back-office.- Parameters:
request
- the front-office request.boRequest
- the request object to be sent to the back-office.
-
-