当前位置: 首页>>代码示例>>Java>>正文


Java WebScriptRequest.getServerPath方法代码示例

本文整理汇总了Java中org.springframework.extensions.webscripts.WebScriptRequest.getServerPath方法的典型用法代码示例。如果您正苦于以下问题:Java WebScriptRequest.getServerPath方法的具体用法?Java WebScriptRequest.getServerPath怎么用?Java WebScriptRequest.getServerPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.springframework.extensions.webscripts.WebScriptRequest的用法示例。


在下文中一共展示了WebScriptRequest.getServerPath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execute

import org.springframework.extensions.webscripts.WebScriptRequest; //导入方法依赖的package包/类
public void execute(WebScriptRequest req, WebScriptResponse res)
    throws IOException
{
    String extensionPath = req.getExtensionPath();
    String[] extensionPaths = extensionPath.split("/");
    if (extensionPaths.length != 2)
    {
        throw new WebScriptException("OpenSearch engine has not been specified as /{engine}/{format}");
    }
    
    // retrieve search engine configuration
    String engine = extensionPaths[0];
    EngineConfig engineConfig = searchConfig.getEngine(engine);
    if (engineConfig == null)
    {
        throw new WebScriptException("OpenSearch engine '" + engine + "' does not exist");
    }
    
    // retrieve engine url as specified by format
    String format = extensionPaths[1];
    String mimetype = formatRegistry.getMimeType(null, format);
    if (mimetype == null)
    {
        throw new WebScriptException("Format '" + format + "' does not map to a registered mimetype");
    }
    Map<String, String> engineUrls = engineConfig.getUrls();
    String engineUrl = engineUrls.get(mimetype);
    if (engineUrl == null)
    {
        throw new WebScriptException("Url mimetype '" + mimetype + "' does not exist for engine '" + engine + "'");
    }

    // replace template url arguments with actual arguments specified on request
    int engineUrlArgIdx = engineUrl.indexOf("?");
    if (engineUrlArgIdx != -1)
    {
        engineUrl = engineUrl.substring(0, engineUrlArgIdx);
    }
    if (req.getQueryString() != null)
    {
        engineUrl += "?" + req.getQueryString();
    }
    
    if (logger.isDebugEnabled())
        logger.debug("Mapping engine '" + engine + "' (mimetype '" + mimetype + "') to url '" + engineUrl + "'");        
    
    // issue request against search engine
    // NOTE: This web script must be executed in a HTTP servlet environment
    if (!(res.getRuntime() instanceof WebScriptServletRuntime))
    {
        throw new WebScriptException("Search Proxy must be executed in HTTP Servlet environment");
    }
    
    HttpServletResponse servletRes = WebScriptServletRuntime.getHttpServletResponse(res);
    SearchEngineHttpProxy proxy = new SearchEngineHttpProxy(req.getServerPath() + req.getServiceContextPath(),
            engine, engineUrl, servletRes, Collections.singletonMap("User-Agent", req.getHeader("User-Agent")));
    proxy.service();
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:59,代码来源:SearchProxy.java


注:本文中的org.springframework.extensions.webscripts.WebScriptRequest.getServerPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。