Package org.ametys.core.ui.dispatcher
Class DispatchGenerator
- java.lang.Object
-
- org.apache.avalon.framework.logger.AbstractLogEnabled
-
- org.apache.cocoon.xml.AbstractXMLProducer
-
- org.apache.cocoon.generation.AbstractGenerator
-
- org.apache.cocoon.generation.ServiceableGenerator
-
- org.ametys.core.ui.dispatcher.DispatchGenerator
-
- All Implemented Interfaces:
Poolable
,Recyclable
,Disposable
,Component
,LogEnabled
,Serviceable
,Generator
,SitemapModelComponent
,XMLProducer
- Direct Known Subclasses:
DispatchGenerator
public class DispatchGenerator extends ServiceableGenerator
This generator read the request incoming from the client org.ametys.servercomm.ServerComm component, then dispatch it to given url and aggregate the result
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
DispatchGenerator.ResponseHandler
Wrap the handler ignore start and end document, but adding a response tag.
-
Field Summary
Fields Modifier and Type Field Description private DispatchProcessExtensionPoint
_dispatchProcessExtensionPoint
private JSONUtils
_jsonUtils
protected RequestAttributesHelper
_requestAttributesHelper
Request Attributes Helperprivate SourceResolver
_resolver
-
Fields inherited from class org.apache.cocoon.generation.ServiceableGenerator
manager
-
Fields inherited from class org.apache.cocoon.generation.AbstractGenerator
objectModel, parameters, resolver, source
-
Fields inherited from class org.apache.cocoon.xml.AbstractXMLProducer
contentHandler, EMPTY_CONTENT_HANDLER, lexicalHandler, xmlConsumer
-
-
Constructor Summary
Constructors Constructor Description DispatchGenerator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private StringBuilder
_buildQueryParameter(String key, Object value)
protected String
_createUrl(String pluginOrWorkspace, String relativeUrl, Map<String,Object> requestParameters)
Create url to callprivate void
_dispatching(Map<String,Object> parametersAsMap, Map<String,Object> contextAsMap)
private String
_escape(String value)
private Map<String,Object>
_extractFiles(String index)
private String
_getRelativePath(String url)
private String
_getRequestBody()
private String
_getRequestContext()
protected String
_getUrlPrefix(String pluginOrWorkspace)
Get the url prefixprivate void
_replaceFiles(Map<String,Object> params, String index)
protected void
_setContextInRequestAttributes(Map<String,Object> contextAsMap)
Set the request attributes from the contextual parametersprivate Throwable
_unroll(Throwable initial)
void
generate()
void
service(ServiceManager smanager)
protected Map<String,Object>
transmitAttributes(Map<String,Object> attributes)
Filters attributes that should be transmitted to the dispatched request-
Methods inherited from class org.apache.cocoon.generation.ServiceableGenerator
dispose
-
Methods inherited from class org.apache.cocoon.generation.AbstractGenerator
recycle, setup
-
Methods inherited from class org.apache.cocoon.xml.AbstractXMLProducer
setConsumer, setContentHandler, setLexicalHandler
-
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.cocoon.xml.XMLProducer
setConsumer
-
-
-
-
Field Detail
-
_requestAttributesHelper
protected RequestAttributesHelper _requestAttributesHelper
Request Attributes Helper
-
_resolver
private SourceResolver _resolver
-
_dispatchProcessExtensionPoint
private DispatchProcessExtensionPoint _dispatchProcessExtensionPoint
-
_jsonUtils
private JSONUtils _jsonUtils
-
-
Constructor Detail
-
DispatchGenerator
public DispatchGenerator()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classServiceableGenerator
- Throws:
ServiceException
-
generate
public void generate() throws IOException, SAXException, ProcessingException
-
_getRequestBody
private String _getRequestBody()
-
_getRequestContext
private String _getRequestContext()
-
_dispatching
private void _dispatching(Map<String,Object> parametersAsMap, Map<String,Object> contextAsMap) throws SAXException
- Throws:
SAXException
-
_replaceFiles
private void _replaceFiles(Map<String,Object> params, String index)
-
_extractFiles
private Map<String,Object> _extractFiles(String index)
-
transmitAttributes
protected Map<String,Object> transmitAttributes(Map<String,Object> attributes)
Filters attributes that should be transmitted to the dispatched request- Parameters:
attributes
- The full list of attributes- Returns:
- The attributes filtered
-
_setContextInRequestAttributes
protected void _setContextInRequestAttributes(Map<String,Object> contextAsMap)
Set the request attributes from the contextual parameters- Parameters:
contextAsMap
- The contextual parameters
-
_createUrl
protected String _createUrl(String pluginOrWorkspace, String relativeUrl, Map<String,Object> requestParameters)
Create url to call- Parameters:
pluginOrWorkspace
- the plugin or workspace namerelativeUrl
- the relative urlrequestParameters
- the request parameters. Can not be null.- Returns:
- the full url
-
_getRelativePath
private String _getRelativePath(String url)
-
_buildQueryParameter
private StringBuilder _buildQueryParameter(String key, Object value)
-
_getUrlPrefix
protected String _getUrlPrefix(String pluginOrWorkspace)
Get the url prefix- Parameters:
pluginOrWorkspace
- the plugin or workspace name- Returns:
- the url prefix
-
-