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.ServletContextAwareController for REST script requests.- Author:
- Alfonso Vásquez
-
-
Field Summary
Fields Modifier and Type Field Description protected static StringAPI_1_SERVICES_ROOTprotected static StringAPI_ROOTstatic StringDEFAULT_ERROR_MESSAGE_MODEL_ATTR_NAMEstatic StringDEFAULT_RESPONSE_BODY_MODEL_ATTR_NAMEprotected booleandisableVariableRestrictionsprotected StringerrorMessageModelAttributeNameprotected PluginServicepluginServiceprotected StringresponseBodyModelAttributeNameprotected ScriptUrlTemplateScannerurlTemplateScanner
-
Constructor Summary
Constructors Constructor Description RestScriptsController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected ThrowablecheckHttpStatusCodeAwareException(Exception e, javax.servlet.http.HttpServletResponse response)protected ThrowablecheckValidationException(Exception e, javax.servlet.http.HttpServletResponse response)protected Map<String,Object>createScriptVariables(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)protected ObjectexecuteScript(ScriptFactory scriptFactory, Map<String,Object> scriptVariables, javax.servlet.http.HttpServletResponse response, String scriptUrl)protected StringgetScriptUrl(ScriptFactory scriptFactory, SiteContext siteContext, javax.servlet.http.HttpServletRequest request, String serviceUrl)protected StringgetServiceUrl(javax.servlet.http.HttpServletRequest request)protected org.springframework.http.ResponseEntityhandleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)protected StringparseScriptUrlForVariables(SiteContext siteContext, String scriptUrl, Map<String,Object> variables)voidsetDisableVariableRestrictions(boolean disableVariableRestrictions)voidsetErrorMessageModelAttributeName(String errorMessageModelAttributeName)voidsetPluginService(PluginService pluginService)voidsetResponseBodyModelAttributeName(String responseBodyModelAttributeName)voidsetServletContext(javax.servlet.ServletContext servletContext)voidsetUrlTemplateScanner(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:
setServletContextin interfaceorg.springframework.web.context.ServletContextAware
-
-