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


Java WebScriptRequest.getExtensionPath方法代码示例

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


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

示例1: executeImpl

import org.springframework.extensions.webscripts.WebScriptRequest; //导入方法依赖的package包/类
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
{
    String path = "/";
    String templatePattern = "*.ftl";
    
    // process extension
    String p = req.getExtensionPath(); // optional
    
    if ((p != null) && (p.length() > 0))
    {
        int idx = p.lastIndexOf("/");
        if (idx != -1)
        {
            path = p.substring(0, idx);
            templatePattern = p.substring(idx+1) + ".ftl";
        }
    }
    
    Set<String> templatePaths = new HashSet<String>();
    for (Store apiStore : searchPath.getStores())
    {
        try
        {
            for (String templatePath : apiStore.getDocumentPaths(path, false, templatePattern))
            {
                templatePaths.add(templatePath);
            }
        }
        catch (IOException e)
        {
            throw new WebScriptException("Failed to search for templates from store " + apiStore, e);
        }
    }

    Map<String, Object> model = new HashMap<String, Object>();
    model.put("paths", templatePaths);
    return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:40,代码来源:TemplatesWebScript.java

示例2: streamContentImpl

import org.springframework.extensions.webscripts.WebScriptRequest; //导入方法依赖的package包/类
protected void streamContentImpl(WebScriptRequest req, WebScriptResponse res, 
        ContentReader reader, NodeRef nodeRef, QName propertyQName, 
        boolean attach, Date modified, String eTag, String attachFileName)
        throws IOException
{
    delegate.setAttachment(req, res, attach, attachFileName);

    // establish mimetype
    String mimetype = reader.getMimetype();
    String extensionPath = req.getExtensionPath();
    if (mimetype == null || mimetype.length() == 0)
    {
        mimetype = MimetypeMap.MIMETYPE_BINARY;
        int extIndex = extensionPath.lastIndexOf('.');
        if (extIndex != -1)
        {
            String ext = extensionPath.substring(extIndex + 1);
            mimetype = mimetypeService.getMimetype(ext);
        }
    }

    // set mimetype for the content and the character encoding + length for the stream
    res.setContentType(mimetype);
    res.setContentEncoding(reader.getEncoding());
    res.setHeader("Content-Length", Long.toString(reader.getSize()));

    // set caching
    Cache cache = new Cache();
    cache.setNeverCache(false);
    cache.setMustRevalidate(true);
    cache.setMaxAge(0L);
    cache.setLastModified(modified);
    cache.setETag(eTag);
    res.setCache(cache);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:36,代码来源:ContentInfo.java

示例3: executeImpl

import org.springframework.extensions.webscripts.WebScriptRequest; //导入方法依赖的package包/类
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
{
    // retrieve ticket from request and current ticket
    String ticket = req.getExtensionPath();
    if (ticket == null || ticket.length() == 0)
    {
        throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Ticket not specified");
    }
    
    // construct model for ticket
    Map<String, Object> model = new HashMap<String, Object>(1, 1.0f);
    model.put("ticket",  ticket);
    
    try
    {
        String ticketUser = ticketComponent.validateTicket(ticket);

        // do not go any further if tickets are different
        if (!AuthenticationUtil.getFullyAuthenticatedUser().equals(ticketUser))
        {
            status.setCode(HttpServletResponse.SC_NOT_FOUND);
            status.setMessage("Ticket not found");
        }
        else
        {
            // delete the ticket
            authenticationService.invalidateTicket(ticket);
            status.setMessage("Deleted Ticket " + ticket);
        }
    }
    catch(AuthenticationException e)
    {
        status.setCode(HttpServletResponse.SC_NOT_FOUND);
        status.setMessage("Ticket not found");
    }

    status.setRedirect(true);
    return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:41,代码来源:LoginTicketDelete.java

示例4: executeImpl

import org.springframework.extensions.webscripts.WebScriptRequest; //导入方法依赖的package包/类
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
{
    // retrieve ticket from request and current ticket
    String ticket = req.getExtensionPath();
    if (ticket == null || ticket.length() == 0)
    {
        throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Ticket not specified");
    }
    
    // construct model for ticket
    Map<String, Object> model = new HashMap<String, Object>(1, 1.0f);
    model.put("ticket",  ticket);
    
    try
    {
        String ticketUser = ticketComponent.validateTicket(ticket);
        
        String currentUser = AuthenticationUtil.getFullyAuthenticatedUser();

        // do not go any further if tickets are different 
        // or the user is not fully authenticated
        if (currentUser == null || !currentUser.equals(ticketUser))
        {
            status.setRedirect(true);
            status.setCode(HttpServletResponse.SC_NOT_FOUND);
            status.setMessage("Ticket not found");
        }
    }
    catch (AuthenticationException e)
    {
        status.setRedirect(true);
        status.setCode(HttpServletResponse.SC_NOT_FOUND);
        status.setMessage("Ticket not found");
    }
    
    return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:39,代码来源:LoginTicket.java

示例5: executeImpl

import org.springframework.extensions.webscripts.WebScriptRequest; //导入方法依赖的package包/类
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
{
    // retrieve requested format
    String format = req.getFormat();
    if (format == null || format.length() == 0)
    {
        format = getDescription().getDefaultFormat();
    }
    
    String extensionPath = req.getExtensionPath();
    String[] extParts = extensionPath == null ? new String[1] : extensionPath.split("/");
    
    String siteId = null;
    if (extParts.length == 1)
    {
       siteId = extParts[0];
    }
    else
    {
        throw new AlfrescoRuntimeException("Unexpected extension: " + extensionPath);
    }
    
    // map feed collection format to feed entry format (if not the same), eg.
    //     atomfeed -> atomentry
    //     atom     -> atomentry
    if (format.equals("atomfeed") || format.equals("atom"))
    {
       format = "atomentry";
    }
    
    Map<String, Object> model = new HashMap<String, Object>();
    
    try
    {
        List<String> feedEntries = activityService.getSiteFeedEntries(siteId);
        
        
        if (format.equals(FeedTaskProcessor.FEED_FORMAT_JSON))
        { 
            model.put("feedEntries", feedEntries);
            model.put("siteId", siteId);
        }
        else
        {
            List<Map<String, Object>> activityFeedModels = new ArrayList<Map<String, Object>>();
            try
            { 
                for (String feedEntry : feedEntries)
                {
                    activityFeedModels.add(JSONtoFmModel.convertJSONObjectToMap(feedEntry));
                }
            }
            catch (JSONException je)
            {    
                throw new AlfrescoRuntimeException("Unable to get user feed entries: " + je.getMessage());
            }
            
            model.put("feedEntries", activityFeedModels);
            model.put("siteId", siteId);
        }
    }
    catch (AccessDeniedException ade)
    {
        // implies that site either does not exist or is private (and current user is not admin or a member) - hence return 401 (unauthorised)
        String currentUser = AuthenticationUtil.getFullyAuthenticatedUser();
        status.setCode(Status.STATUS_UNAUTHORIZED);
        logger.warn("Unable to get site feed entries for '" + siteId + "' (site does not exist or is private) - currently logged in as '" + currentUser +"'");
        
        model.put("feedEntries", null);
        model.put("siteId", "");
    }
    
    return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:76,代码来源:SiteFeedRetrieverWebScript.java

示例6: 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.getExtensionPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。