Class RestScriptsController
- java.lang.Object
-
- org.craftercms.engine.controller.rest.RestScriptsController
-
- All Implemented Interfaces:
org.springframework.beans.factory.Aware
,org.springframework.web.context.ServletContextAware
@RequestMapping(path={"/api","/api/1/services"}) public class RestScriptsController extends Object implements org.springframework.web.context.ServletContextAware
Controller for REST script requests.- Author:
- Alfonso Vásquez
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
API_1_SERVICES_ROOT
protected static String
API_ROOT
static String
DEFAULT_ERROR_MESSAGE_MODEL_ATTR_NAME
static String
DEFAULT_RESPONSE_BODY_MODEL_ATTR_NAME
protected boolean
disableVariableRestrictions
protected String
errorMessageModelAttributeName
protected PluginService
pluginService
protected String
responseBodyModelAttributeName
protected ScriptUrlTemplateScanner
urlTemplateScanner
-
Constructor Summary
Constructors Constructor Description RestScriptsController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected Throwable
checkHttpStatusCodeAwareException(Exception e, javax.servlet.http.HttpServletResponse response)
protected Throwable
checkValidationException(Exception e, javax.servlet.http.HttpServletResponse response)
protected Map<String,Object>
createScriptVariables(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
protected Object
executeScript(ScriptFactory scriptFactory, Map<String,Object> scriptVariables, javax.servlet.http.HttpServletResponse response, String scriptUrl)
protected String
getScriptUrl(ScriptFactory scriptFactory, SiteContext siteContext, javax.servlet.http.HttpServletRequest request, String serviceUrl)
protected String
getServiceUrl(javax.servlet.http.HttpServletRequest request)
protected org.springframework.http.ResponseEntity
handleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
protected String
parseScriptUrlForVariables(SiteContext siteContext, String scriptUrl, Map<String,Object> variables)
void
setDisableVariableRestrictions(boolean disableVariableRestrictions)
void
setErrorMessageModelAttributeName(String errorMessageModelAttributeName)
void
setPluginService(PluginService pluginService)
void
setResponseBodyModelAttributeName(String responseBodyModelAttributeName)
void
setServletContext(javax.servlet.ServletContext servletContext)
void
setUrlTemplateScanner(ScriptUrlTemplateScanner urlTemplateScanner)
-
-
-
Field Detail
-
DEFAULT_RESPONSE_BODY_MODEL_ATTR_NAME
public static final String DEFAULT_RESPONSE_BODY_MODEL_ATTR_NAME
- See Also:
- Constant Field Values
-
DEFAULT_ERROR_MESSAGE_MODEL_ATTR_NAME
public static final String DEFAULT_ERROR_MESSAGE_MODEL_ATTR_NAME
- See Also:
- Constant Field Values
-
API_ROOT
protected static final String API_ROOT
- See Also:
- Constant Field Values
-
API_1_SERVICES_ROOT
protected static final String API_1_SERVICES_ROOT
- See Also:
- Constant Field Values
-
responseBodyModelAttributeName
protected String responseBodyModelAttributeName
-
errorMessageModelAttributeName
protected String errorMessageModelAttributeName
-
urlTemplateScanner
protected ScriptUrlTemplateScanner urlTemplateScanner
-
disableVariableRestrictions
protected boolean disableVariableRestrictions
-
pluginService
protected PluginService pluginService
-
-
Method Detail
-
setResponseBodyModelAttributeName
public void setResponseBodyModelAttributeName(String responseBodyModelAttributeName)
-
setErrorMessageModelAttributeName
public void setErrorMessageModelAttributeName(String errorMessageModelAttributeName)
-
setUrlTemplateScanner
public void setUrlTemplateScanner(ScriptUrlTemplateScanner urlTemplateScanner)
-
setDisableVariableRestrictions
public void setDisableVariableRestrictions(boolean disableVariableRestrictions)
-
setPluginService
public void setPluginService(PluginService pluginService)
-
handleRequest
@RequestMapping(path="/**", produces={"application/json","application/xml"}) protected org.springframework.http.ResponseEntity handleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
-
getServiceUrl
protected String getServiceUrl(javax.servlet.http.HttpServletRequest request)
-
parseScriptUrlForVariables
protected String parseScriptUrlForVariables(SiteContext siteContext, String scriptUrl, Map<String,Object> variables)
-
getScriptUrl
protected String getScriptUrl(ScriptFactory scriptFactory, SiteContext siteContext, javax.servlet.http.HttpServletRequest request, String serviceUrl)
-
createScriptVariables
protected Map<String,Object> createScriptVariables(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
-
executeScript
protected Object executeScript(ScriptFactory scriptFactory, Map<String,Object> scriptVariables, javax.servlet.http.HttpServletResponse response, String scriptUrl)
-
checkHttpStatusCodeAwareException
protected Throwable checkHttpStatusCodeAwareException(Exception e, javax.servlet.http.HttpServletResponse response)
-
checkValidationException
protected Throwable checkValidationException(Exception e, javax.servlet.http.HttpServletResponse response)
-
setServletContext
public void setServletContext(javax.servlet.ServletContext servletContext)
- Specified by:
setServletContext
in interfaceorg.springframework.web.context.ServletContextAware
-
-