gpt4 book ai didi

org.springframework.extensions.webscripts.WebScriptException类的使用及代码示例

转载 作者:知者 更新时间:2024-03-26 21:01:05 34 4
gpt4 key购买 nike

本文整理了Java中org.springframework.extensions.webscripts.WebScriptException类的一些代码示例,展示了WebScriptException类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebScriptException类的具体详情如下:
包路径:org.springframework.extensions.webscripts.WebScriptException
类名称:WebScriptException

WebScriptException介绍

[英]Web Script Exceptions.
[中]Web脚本异常。

代码示例

代码示例来源: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

public StatusTemplate getStatusTemplate()
  {
    int statusCode = we.getStatus();
    String format = req.getFormat();
    String scriptId = getDescription().getId();
    return AbstractWebScript.this.getStatusTemplate(scriptId, statusCode, (format == null) ? "" : format);
  }
});

代码示例来源:origin: org.alfresco.surf/spring-webscripts

/**
 * Attach an advanced description of the status code associated to this exception
 * 
 * @param statusTemplate  status template
 * @param statusModel  template model
 * @deprecated
 */
public void setStatusTemplate(final StatusTemplate statusTemplate, final Map<String, Object> statusModel)
{
  setStatusTemplateFactory(new StatusTemplateFactory()
  {
    public Map<String, Object> getStatusModel()
    {
      return statusModel;
    }
    public StatusTemplate getStatusTemplate()
    {
      return statusTemplate;
    }
  });
}

代码示例来源: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)
    throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, msg);
    throw new WebScriptException(HttpServletResponse.SC_METHOD_NOT_ALLOWED, msg);
  if (e instanceof WebScriptException && (((WebScriptException)e).getStatus() == HttpServletResponse.SC_NOT_FOUND || 
                      ((WebScriptException)e).getStatus() == HttpServletResponse.SC_UNAUTHORIZED))
    String errorCode = ((WebScriptException)e).getStatus() == HttpServletResponse.SC_NOT_FOUND ? "NOT FOUND" : "UNAUTHORIZED";
    logger.debug("Webscript did not execute. (" + errorCode + "): " + e.getMessage());
    statusCode = we.getStatus();
    statusTemplate = we.getStatusTemplate();
    statusModel = we.getStatusModel();
        throw new WebScriptException("Failed to find status template " + statusTemplate.getPath() + " (format: " + statusTemplate.getFormat() + ")");
    throw new WebScriptException("Web Script format '" + statusTemplate.getFormat() + "' is not registered");
    throw new WebScriptException("Internal error", e1);

代码示例来源:origin: org.alfresco.surf/spring-webscripts

wildcard = true;
if (desc.getFormatStyle() != Description.FormatStyle.argument)
String uriIdx = desc.getMethod() + ":" + uri;
if (index.containsKey(uriIdx))
  if (!existingService.getDescription().getId().equals(desc.getId()))
    String msg = "Web Script document " + desc.getDescPath() + " is attempting to define the url '" + uriIdx + "' already defined by " + existingService.getDescription().getDescPath();
    throw new WebScriptException(msg);

代码示例来源: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() + ")");
  if (e instanceof WebScriptException && (((WebScriptException)e).getStatus() == HttpServletResponse.SC_NOT_FOUND || 
                      ((WebScriptException)e).getStatus() == HttpServletResponse.SC_UNAUTHORIZED))
    String errorCode = ((WebScriptException)e).getStatus() == HttpServletResponse.SC_NOT_FOUND ? "NOT FOUND" : "UNAUTHORIZED";
    logger.debug("Webscript did not execute. (" + errorCode + "): " + e.getMessage());

代码示例来源:origin: org.springframework.extensions.surf/spring-webscripts

if (match != null && match.getKind() != Match.Kind.URI)
  Description desc = match.getWebScript().getDescription();
  FormatStyle style = desc.getFormatStyle();
        throw new WebScriptException("Format specified both in extension and format argument");
    NegotiatedFormat[] negotiatedFormats = desc.getNegotiatedFormats();
    if (accept != null && negotiatedFormats != null)
      if (format == null)
        throw new WebScriptException(HttpServletResponse.SC_NOT_ACCEPTABLE, "Cannot negotiate appropriate response format for Accept: " + accept);
    format = desc.getDefaultFormat();

代码示例来源: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");
    Cache cache = new Cache(getDescription().getRequiredCache());
    Map<String, Object> model = executeImpl(req, status, cache);
    if (model == null)
      ScriptDetails script = getExecuteScript(req.getContentType());
      if (script != null)
        if (getContainer().allowCallbacks())
          callback = req.getJSONCallback();

代码示例来源:origin: stackoverflow.com

@Override
protected void executeImpl(Action action, NodeRef actionedUponNodeRef) {
  if (condition) {
  // Do something
  } else {
      throw new WebScriptException("Action is failed");                        
      }
  }

代码示例来源: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");
for (WebScript webscript : webscripts)
  TypeDescription[] requests = webscript.getDescription().getRequestTypes();
  if (requests != null)
  TypeDescription[] responses = webscript.getDescription().getResponseTypes();
  if (responses != null)

代码示例来源:origin: org.springframework.extensions.surf/spring-webscripts

logger.debug("Initialising Web Scripts (Container: " + container.getName() + ", URI index: " + uriIndex.getClass().getName() + ")");
    throw new WebScriptException("Failed to search for package descriptions in store " + apiStore, e);
        throw new WebScriptException("Failed to read package description document " + apiStore.getBasePath() + packageDescPath, e);
    throw new WebScriptException("Failed to search for schema descriptions in store " + apiStore, e);
        throw new WebScriptException("Failed to read Web Script description document " + apiStore.getBasePath() + schemaDescPath, e);
    throw new WebScriptException("Failed to search for web scripts in store " + apiStore, e);
        throw new WebScriptException("Failed to read Web Script description document " + apiStore.getBasePath() + serviceDescPath, e);
          Description existingDesc = existingService.getDescription();
          String msg = "Web Script description document " + serviceDesc.getStorePath() + "/" + serviceDesc.getDescPath();
          msg += " overridden by " + existingDesc.getStorePath() + "/" + existingDesc.getDescPath();
          logger.debug(msg);
          throw new WebScriptException("Web Script kind '" + kind + "' is unknown");
          throw new WebScriptException("Failed to parse extensions from Web Script description document " + apiStore.getBasePath() + serviceDescPath, e);
          logger.debug("Registered Web Script URL '" + serviceImpl.getDescription().getMethod() + ":" + uriTemplate + "'");

代码示例来源: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().getLifecycle(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("lifecycle",  path);
  return model;
}

代码示例来源:origin: org.springframework.extensions.surf/spring-webscripts

String scriptId = getDescription().getId();
StatusTemplate template = getStatusTemplate(scriptId, statusCode, statusFormat);
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.setStatus(req.forceSuccessStatus() ? HttpServletResponse.SC_OK : statusCode);
String location = status.getLocation();
if (location != null && location.length() > 0)

代码示例来源:origin: org.alfresco/alfresco-repository

int startIndex = 0;
String queryId = req.getParameter("queryId");
String pageSizeS = req.getParameter("pageSize");
if (pageSizeS != null)
   throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Paging size parameters invalid");
String startIndexS = req.getParameter("startIndex");
if (startIndexS != null)
   throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Paging size parameters invalid");
    throw new WebScriptException(Status.STATUS_BAD_REQUEST, "Paging size parameters invalid");

代码示例来源:origin: deas/alfresco

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");
Collection<Store> stores = getContainer().getSearchPath().getStores();
for (Store store : stores)
    throw new WebScriptException("Failed to search for documents for script "
        + script.getDescription().getId() + " in store " + store, e);

代码示例来源: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();
      throw new WebScriptException("Failed to find status template " + statusTemplate.getPath() + " (format: " + statusTemplate.getFormat() + ")");
  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)
  throw new WebScriptException("Web Script format '" + statusTemplate.getFormat() + "' is not registered");
  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);
  throw new WebScriptException("Internal error", e1);

代码示例来源:origin: org.springframework.extensions.surf/spring-webscripts

String configPath = getDescription().getId() + ".config.xml";
  input = this.container.getSearchPath().getDocument(configPath);
  if (input != null)
  throw new WebScriptException("Failed to read script configuration file", ioe);
this.scriptConfigModel = new ScriptConfigModel(this.container.getConfigService(), this.xmlConfig);
this.templateConfigModel = new TemplateConfigModel(this.container.getConfigService(), this.xmlConfig);

代码示例来源:origin: deas/alfresco

throw new WebScriptException("Web Script install only supported via HTTP Servlet");
  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");
  throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Web Script install request is missing file upload");
if (nodes.size() == 0)
  throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Cannot locate Web Script in uploaded file");
if (scriptId == null || scriptId.length() == 0)
  throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Expected scriptid value on webscript element");
  if (webscriptStore == null || webscriptStore.length() == 0)
    throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Expected store value on webscript element");
    throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Expected file value on webscript element");
  throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Failed to install Web Script " + scriptId);
throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());
throw new WebScriptException(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getMessage());

代码示例来源:origin: org.alfresco.surf/spring-webscripts

/**
 * Render a template (contents as string)
 *  
 * @param template  the template
 * @param model  model
 * @param writer  output writer
 * @param extension optional template extension type (i.e. ftl, php) 
 */
final protected void renderString(String template, Map<String, Object> model, Writer writer, String extension)
{        
  TemplateProcessor processor = container.getTemplateProcessorRegistry().getTemplateProcessorByExtension(extension);
  
  if (processor != null)
  {
    processor.processString(template, model, writer);
  }
  else
  {
    throw new WebScriptException("No processor found for extension " + extension);
  }
}

代码示例来源: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");
  try
    serviceDescIS = desc.getDescDocument();
    OutputStream out = res.getOutputStream();
    res.setContentType(Format.XML.mimetype() + ";charset=UTF-8");
    throw new WebScriptException("Failed to read Web Script description document for '" + scriptId + "'", e);

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com