本文整理了Java中org.springframework.extensions.webscripts.WebScriptRequest
类的一些代码示例,展示了WebScriptRequest
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebScriptRequest
类的具体详情如下:
包路径:org.springframework.extensions.webscripts.WebScriptRequest
类名称:WebScriptRequest
[英]Web Script Request
[中]Web脚本请求
代码示例来源:origin: org.alfresco.surf/spring-surf
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
String surfBugStatusUpdate = req.getParameter(UPDATE_STATUS_REQUEST_PARAMETER);
this.webFrameworkConfigElement.setSurfBugEnabled(surfBugStatusUpdate != null && surfBugStatusUpdate.equals(DEBUG_ENABLED));
Map<String, Object> model = new HashMap<String, Object>(7, 1.0f);
model.put("surfbugEnabled", this.webFrameworkConfigElement.isSurfBugEnabled());
return model;
}
}
代码示例来源:origin: org.alfresco.surf/spring-webscripts
/**
* Gets the values of template variables
*
* @return map of value indexed by variable name (or the empty map)
*/
public Map<String, String> getTemplateArgs()
{
Map<String, String> args = req.getServiceMatch().getTemplateVars();
return (args == null) ? emptyArgs : args;
}
}
代码示例来源:origin: org.springframework.extensions.surf/spring-webscripts
Content content = req.getContent();
if (content == null)
throw new WebScriptException("Failed to convert request to JSON");
try
String jsonString = content.getContent();
if (jsonString.startsWith("[") == true)
result = new JSONObject(jsonString);
throw new WebScriptException("Failed to convert request to JSON", exception);
代码示例来源:origin: org.alfresco.surf/spring-webscripts
/**
* Create a map of (array) arguments from Web Script Request (for scripting)
*
* @param req Web Script Request
* @return argument map
*/
final protected Map<String, String[]> createArgsM(WebScriptRequest req)
{
String[] names = req.getParameterNames();
Map<String, String[]> args = new HashMap<String, String[]>(names.length, 1.0f);
for (String name : names)
{
args.put(name, req.getParameterValues(name));
}
return args;
}
代码示例来源:origin: deas/alfresco
/**
* Create a map of arguments from Web Script Request (for scripting)
*
* @param req Web Script Request
* @return argument map
*/
final protected Map<String, String> createArgs(WebScriptRequest req)
{
String[] names = req.getParameterNames();
Map<String, String> args = new HashMap<String, String>(names.length, 1.0f);
for (String name : names)
{
args.put(name, req.getParameter(name));
}
return args;
}
代码示例来源:origin: org.springframework.extensions.surf/spring-surf
String[] moduleIdsToDeploy = req.getParameterValues("deployedModules");
if (moduleIdsToDeploy == null)
JSONObject modAsJson = new JSONObject(modAsJsonStr);
modulesToDeploy.add(modAsJson);
代码示例来源:origin: org.springframework.extensions.surf/spring-webscripts
if (scriptUrl == null || scriptUrl.length() == 0)
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Script URL not specified");
if ((match != null) && (match.getWebScript().getDescription().getRequiredAuthentication().equals(RequiredAuthentication.none)))
if (match == null || match.getKind() == Match.Kind.URI)
if (debug) logger.debug("Agent: " + scriptReq.getAgent());
String reqFormat = scriptReq.getFormat();
String format = (reqFormat == null || reqFormat.length() == 0) ? "[undefined]" : reqFormat;
Description desc = scriptReq.getServiceMatch().getWebScript().getDescription();
logger.debug("Invoking Web Script " + description.getId() + " (format " + format + ", style: " + desc.getFormatStyle() + ", default: " + desc.getDefaultFormat() + ")");
String format = req.getFormat();
String mimetype = container.getFormatRegistry().getMimeType(req.getAgent(), statusTemplate.getFormat());
if (mimetype == null)
logger.debug("Force success status header in response: " + req.forceSuccessStatus());
logger.debug("Sending status " + statusCode + " (Template: " + statusTemplate.getPath() + ")");
logger.debug("Rendering response: content type=" + mimetype);
res.setCache(cache);
res.setStatus(req.forceSuccessStatus() ? HttpServletResponse.SC_OK : statusCode);
res.setContentType(mimetype + ";charset=UTF-8");
try
代码示例来源:origin: org.alfresco.surf/spring-webscripts
final public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException
String format = req.getFormat();
String mimetype = getContainer().getFormatRegistry().getMimeType(req.getAgent(), format);
if (mimetype == null)
throw new WebScriptException("Web Script format '" + format + "' is not registered");
ScriptDetails script = getExecuteScript(req.getContentType());
if (script != null)
if (statusCode != HttpServletResponse.SC_OK && !req.forceSuccessStatus())
logger.debug("Force success status header in response: " + req.forceSuccessStatus());
logger.debug("Setting status " + statusCode);
res.setStatus(statusCode);
res.setHeader(WebScriptResponse.HEADER_LOCATION, location);
res.setCache(cache);
if (getContainer().allowCallbacks())
callback = req.getJSONCallback();
代码示例来源:origin: org.springframework.extensions.surf/spring-webscripts
String mimetype = container.getFormatRegistry().getMimeType(req.getAgent(), template.getFormat());
if (mimetype == null)
throw new WebScriptException("Web Script format '" + template.getFormat() + "' is not registered");
logger.debug("Force success status header in response: " + req.forceSuccessStatus());
logger.debug("Sending status " + statusCode + " (Template: " + template.getPath() + ")");
logger.debug("Rendering response: content type=" + mimetype);
res.reset();
res.setCache(cache);
res.setStatus(req.forceSuccessStatus() ? HttpServletResponse.SC_OK : statusCode);
String location = status.getLocation();
if (location != null && location.length() > 0)
代码示例来源:origin: org.springframework.extensions.surf/spring-surf
res.setContentType(Format.JAVASCRIPT.mimetype() + ";charset=UTF-8");
res.setCache(cache);
String locale = req.getParameter("locale");
if (locale == null || locale.length() == 0)
throw new WebScriptException("Locale parameter is mandatory.");
res.getWriter().write(result);
res.getWriter().flush();
res.getWriter().close();
代码示例来源:origin: org.alfresco.surf/spring-webscripts
StatusTemplate statusTemplate = null;
Map<String, Object> statusModel = null;
String format = request.getFormat();
statusCode = we.getStatus();
statusTemplate = we.getStatusTemplate();
statusModel = we.getStatusModel();
statusModel.putAll(container.getTemplateParameters());
statusModel.put("url", createURLModel(request));
if (match != null && match.getWebScript() != null)
statusModel.put("webscript", match.getWebScript().getDescription());
String mimetype = container.getFormatRegistry().getMimeType(request.getAgent(), statusTemplate.getFormat());
if (mimetype == null)
logger.debug("Force success status header in response: " + request.forceSuccessStatus());
logger.debug("Sending status " + statusCode + " (Template: " + statusTemplate.getPath() + ")");
logger.debug("Rendering response: content type=" + mimetype);
response.setStatus(request.forceSuccessStatus() ? HttpServletResponse.SC_OK : statusCode);
response.setContentType(mimetype + ";charset=UTF-8");
statusProcessor.process(validTemplatePath, statusModel, response.getWriter());
代码示例来源:origin: org.springframework.extensions.surf/spring-webscripts
params.put("webscript", req.getServiceMatch().getWebScript().getDescription());
params.put("format", new FormatModel(container.getFormatRegistry(), req.getFormat()));
params.put("args", createArgs(req));
params.put("argsM", createArgsM(req));
params.put("headers", createHeaders(req));
params.put("headersM", createHeadersM(req));
params.put("guest", req.isGuest());
params.put("url", createURLModel(req));
params.put("msg", getScriptMessage());
final String contentType = req.getContentType();
if (script != null)
FormatReader<Object> reader = container.getFormatRegistry().getReader(script.getRequestType());
if (!(WebScriptRequestImpl.MULTIPART_FORM_DATA.equals(contentType) && getDescription().getMultipartProcessing() == false))
params.putAll(req.getRuntime().getScriptParameters());
params.putAll(container.getScriptParameters());
代码示例来源:origin: org.alfresco.surf/spring-webscripts
params.putAll(req.getRuntime().getTemplateParameters());
params.putAll(container.getTemplateParameters());
params.put("webscript", req.getServiceMatch().getWebScript().getDescription());
params.put("format", new FormatModel(container.getFormatRegistry(), req.getFormat()));
params.put("args", createArgs(req));
params.put("argsM", createArgsM(req));
params.put("headers", createHeaders(req));
params.put("headersM", createHeadersM(req));
params.put("guest", req.isGuest());
params.put("url", createURLModel(req));
params.put("absurl", new AbsoluteUrlMethod(req.getServerPath()));
params.put("formatwrite", new FormatWriterMethod(container.getFormatRegistry(), req.getFormat()));
params.put("message", getMessageMethod()); // for compatibility with repo templates
params.put("msg", getMessageMethod()); // short form for presentation webscripts
代码示例来源:origin: org.alfresco.surf/spring-webscripts
if (scriptUrl == null || scriptUrl.length() == 0)
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Script URL not specified");
if ((match != null) && (match.getWebScript().getDescription().getRequiredAuthentication().equals(RequiredAuthentication.none)))
if (match == null || match.getKind() == Match.Kind.URI)
throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, msg);
throw new WebScriptException(HttpServletResponse.SC_METHOD_NOT_ALLOWED, msg);
if (debug) logger.debug("Agent: " + scriptReq.getAgent());
final WebScript script = match.getWebScript();
final Description description = script.getDescription();
String reqFormat = scriptReq.getFormat();
String format = (reqFormat == null || reqFormat.length() == 0) ? "[undefined]" : reqFormat;
Description desc = scriptReq.getServiceMatch().getWebScript().getDescription();
logger.debug("Invoking Web Script " + description.getId() + " (format " + format + ", style: " + desc.getFormatStyle() + ", default: " + desc.getDefaultFormat() + ")");
res.setCache(cache);
代码示例来源:origin: deas/alfresco
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
{
// extract web script package
String uriPath = req.getExtensionPath();
if (uriPath == null || uriPath.length() == 0)
{
uriPath = "/";
}
if (!uriPath.startsWith("/"))
{
uriPath = "/" + uriPath;
}
// locate web script package
Path path = getContainer().getRegistry().getUri(uriPath);
if (path == null)
{
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Web Script URI '" + uriPath + "' not found");
}
Map<String, Object> model = new HashMap<String, Object>(7, 1.0f);
model.put("uri", path);
return model;
}
代码示例来源:origin: org.alfresco.surf/spring-webscripts
public String encodeScriptUrl(String url)
{
WebScriptRequest req = new WebScriptPortletRequest(getRuntime(), null, url, null);
PortletURL portletUrl = res.createActionURL();
portletUrl.setParameter("scriptUrl", req.getServicePath());
String[] parameterNames = req.getParameterNames();
for (String parameterName : parameterNames)
{
portletUrl.setParameter("arg." + parameterName, req.getParameter(parameterName));
}
return portletUrl.toString();
}
代码示例来源:origin: deas/alfresco
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException
String scriptId = req.getExtensionPath();
if (scriptId == null || scriptId.length() == 0)
throw new WebScriptException("Web Script Id not provided");
WebScript script = getContainer().getRegistry().getWebScript(scriptId);
if (script == null)
throw new WebScriptException("Web Script Id '" + scriptId + "' not found");
OutputStream out = res.getOutputStream();
res.setContentType(Format.XML.mimetype() + ";charset=UTF-8");
byte[] buffer = new byte[2048];
int read = serviceDescIS.read(buffer);
throw new WebScriptException("Failed to read Web Script description document for '" + scriptId + "'", e);
代码示例来源:origin: deas/alfresco
throw new WebScriptException("Web Script install only supported via HTTP Servlet");
Object content = req.parseContent();
if (content == null || !(content instanceof FormData))
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Web Script install request is not multipart/form-data");
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Web Script install request expects only one file upload");
InputStream fileIS = file.getContent().getInputStream();
try
getContainer().reset();
Registry registry = getContainer().getRegistry();
WebScript webscript = registry.getWebScript(scriptId);
if (webscript == null)
代码示例来源:origin: deas/alfresco
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
String packagePath = "/" + templateVars.get("package");
Registry registry = getContainer().getRegistry();
Path path = registry.getPackage(packagePath);
if (path == null)
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Web Script Package '" + packagePath + "' not found");
if (packageDoc == null)
throw new WebScriptException(Status.STATUS_NOT_FOUND, "Web Script documentation for package '" + packagePath + "' not found");
代码示例来源:origin: deas/alfresco
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
{
List<String> tasks = new ArrayList<String>();
// reset index
String reset = req.getParameter("reset");
if (reset != null && reset.equals("on"))
{
// reset list of web scripts
int previousCount = getContainer().getRegistry().getWebScripts().size();
int previousFailures = getContainer().getRegistry().getFailures().size();
getContainer().reset();
tasks.add("Reset Web Scripts Registry; registered " + getContainer().getRegistry().getWebScripts().size() + " Web Scripts. Previously, there were " + previousCount + ".");
int newFailures = getContainer().getRegistry().getFailures().size();
if (newFailures != 0 || previousFailures != 0)
{
tasks.add("Warning: found " + newFailures + " broken Web Scripts. Previously, there were " + previousFailures + ".");
}
}
// create model for rendering
Map<String, Object> model = new HashMap<String, Object>(7, 1.0f);
model.put("tasks", tasks);
model.put("webscripts", getContainer().getRegistry().getWebScripts());
model.put("failures", getContainer().getRegistry().getFailures());
return model;
}
内容来源于网络,如有侵权,请联系作者删除!