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


Java HttpServletResponse.SC_NOT_FOUND属性代码示例

本文整理汇总了Java中javax.servlet.http.HttpServletResponse.SC_NOT_FOUND属性的典型用法代码示例。如果您正苦于以下问题:Java HttpServletResponse.SC_NOT_FOUND属性的具体用法?Java HttpServletResponse.SC_NOT_FOUND怎么用?Java HttpServletResponse.SC_NOT_FOUND使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.servlet.http.HttpServletResponse的用法示例。


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

示例1: executeImpl

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
    Map<String, Object> model = new HashMap<String, Object>();

    // get request parameters
    Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
    String name = templateVars.get("name");

    // get specified parameter constraint
    ParameterConstraint parameterConstraint = actionService.getParameterConstraint(name);

    if (parameterConstraint == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find parameter constraint with name: " + name);
    }

    model.put("actionConstraint", parameterConstraint);

    return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:21,代码来源:ActionConstraintGet.java

示例2: parseRequestForNodeRef

protected NodeRef parseRequestForNodeRef(WebScriptRequest req)
{
    // get the parameters that represent the NodeRef, we know they are present
    // otherwise this webscript would not have matched
    Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
    String storeType = templateVars.get("store_type");
    String storeId = templateVars.get("store_id");
    String nodeId = templateVars.get("id");

    // create the NodeRef and ensure it is valid
    StoreRef storeRef = new StoreRef(storeType, storeId);
    NodeRef nodeRef = new NodeRef(storeRef, nodeId);

    if (!this.nodeService.exists(nodeRef))
    {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find node: " + nodeRef.toString());
    }

    return nodeRef;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:20,代码来源:AbstractRatingWebScript.java

示例3: execute

@Override
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException
{
    // create empty map of args
    Map<String, String> args = new HashMap<String, String>(0, 1.0f);
    // create map of template vars
    Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
    // create object reference from url
    ObjectReference reference = createObjectReferenceFromUrl(args, templateVars);
    NodeRef nodeRef = reference.getNodeRef();
    if (nodeRef == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find " + reference.toString());
    }

    // render content
    QName propertyQName = ContentModel.PROP_CONTENT;

    // Stream the content
    streamContent(req, res, nodeRef, propertyQName, false, null, null);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:21,代码来源:ContentInfo.java

示例4: buildModel

@Override
protected Map<String, Object> buildModel(WorkflowModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache)
{
    Map<String, String> params = req.getServiceMatch().getTemplateVars();

    // getting task id from request parameters
    String taskId = params.get("task_instance_id");

    // searching for task in repository
    WorkflowTask workflowTask = workflowService.getTaskById(taskId);

    // task was not found -> return 404
    if (workflowTask == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find workflow task with id: " + taskId);
    }

    Map<String, Object> model = new HashMap<String, Object>();
    // build the model for ftl
    model.put("workflowTask", modelBuilder.buildDetailed(workflowTask));

    return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:23,代码来源:TaskInstanceGet.java

示例5: buildModel

@Override
protected Map<String, Object> buildModel(WorkflowModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache)
{
    Map<String, String> params = req.getServiceMatch().getTemplateVars();

    // Get the definition id from the params
    String workflowDefinitionId = params.get(PARAM_WORKFLOW_DEFINITION_ID);
    
    WorkflowDefinition workflowDefinition = workflowService.getDefinitionById(workflowDefinitionId);

    // Workflow definition is not found, 404
    if (workflowDefinition == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, 
                    "Unable to find workflow definition with id: " + workflowDefinitionId);
    }
    
    Map<String, Object> model = new HashMap<String, Object>();
    model.put("workflowDefinition", modelBuilder.buildDetailed(workflowDefinition));
    return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:21,代码来源:WorkflowDefinitionGet.java

示例6: buildModel

@Override
protected Map<String, Object> buildModel(WorkflowModelBuilder modelBuilder, WebScriptRequest req, Status status, Cache cache)
{
    Map<String, String> params = req.getServiceMatch().getTemplateVars();

    // getting workflow instance id from request parameters
    String workflowInstanceId = params.get("workflow_instance_id");

    boolean includeTasks = getIncludeTasks(req);

    WorkflowInstance workflowInstance = workflowService.getWorkflowById(workflowInstanceId);

    // task was not found -> return 404
    if (workflowInstance == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find workflow instance with id: " + workflowInstanceId);
    }

    Map<String, Object> model = new HashMap<String, Object>();
    // build the model for ftl
    model.put("workflowInstance", modelBuilder.buildDetailed(workflowInstance, includeTasks));

    return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:24,代码来源:WorkflowInstanceGet.java

示例7: parseRequestForNodeRef

/**
 * Parses the request and providing it's valid returns the NodeRef.
 * 
 * @param req The webscript request
 * @return The NodeRef passed in the request
 * 
 */
protected NodeRef parseRequestForNodeRef(WebScriptRequest req)
{
    // get the parameters that represent the NodeRef, we know they are present
    // otherwise this webscript would not have matched
    Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
    String storeType = templateVars.get("store_type");
    String storeId = templateVars.get("store_id");
    String nodeId = templateVars.get("id");

    // create the NodeRef and ensure it is valid
    StoreRef storeRef = new StoreRef(storeType, storeId);
    NodeRef nodeRef = new NodeRef(storeRef, nodeId);

    if (!this.nodeService.exists(nodeRef))
    {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find node: " + nodeRef.toString());
    }

    return nodeRef;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:27,代码来源:AbstractRuleWebScript.java

示例8: getErrorMessageByStatusCode

private String getErrorMessageByStatusCode(String requestPath, final int statusCode) {
	String errMessage;
	switch (statusCode) {
       case HttpServletResponse.SC_NOT_FOUND:
           errMessage = MessageFormat.format(ERROR_PATH_NOT_FOUND, requestPath);
           break;
       case HttpServletResponse.SC_UNAUTHORIZED:
           errMessage = MessageFormat.format(ERROR_WRONG_CREDENTIALS, requestPath);
           break;
       case HttpServletResponse.SC_FORBIDDEN:
           errMessage = MessageFormat.format(ERROR_UNAUTHORIZED, requestPath);
           break;
       default:
           errMessage = MessageFormat.format(ERROR_UNEXPECTED_RESPONSE, requestPath);
       }
	return errMessage;
}
 
开发者ID:SAP,项目名称:cloud-c4c-ticket-duplicate-finder-ext,代码行数:17,代码来源:DefaultHTTPResponseValidator.java

示例9: copyContentOnly

private void copyContentOnly(FileInfo sourceFileInfo, FileInfo destFileInfo, FileFolderService fileFolderService) throws WebDAVServerException
{
	ContentService contentService = getContentService();
    ContentReader reader = contentService.getReader(sourceFileInfo.getNodeRef(), ContentModel.PROP_CONTENT);
    if (reader == null)
    {
        // There is no content for the node if it is a folder
        if (!sourceFileInfo.isFolder())
        {
            // Non-folders should have content available.
            logger.error("Unable to get ContentReader for source node " + sourceFileInfo.getNodeRef());
            throw new WebDAVServerException(HttpServletResponse.SC_NOT_FOUND);
        }
    }
    else
    {
        ContentWriter contentWriter = contentService.getWriter(destFileInfo.getNodeRef(), ContentModel.PROP_CONTENT, true);
        contentWriter.putContent(reader);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:20,代码来源:MoveMethod.java

示例10: execute

@Override
public void execute(WebScriptRequest req, WebScriptResponse res) throws IOException
{
    Map<String, String> params = req.getServiceMatch().getTemplateVars();

    // getting workflow instance id from request parameters
    String workflowInstanceId = params.get("workflow_instance_id");
    
    WorkflowInstance workflowInstance = workflowService.getWorkflowById(workflowInstanceId);

    // workflow instance was not found -> return 404
    if (workflowInstance == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find workflow instance with id: " + workflowInstanceId);
    }
    
    // check whether there is a diagram available
    if (!workflowService.hasWorkflowImage(workflowInstanceId))
    {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find diagram for workflow instance with id: " + workflowInstanceId);
    }
    
    // copy image data into temporary file
    File file = TempFileProvider.createTempFile("workflow-diagram-", ".png");
    InputStream imageData = workflowService.getWorkflowImage(workflowInstanceId);
    OutputStream os = new FileOutputStream(file);
    FileCopyUtils.copy(imageData, os);
    
    // stream temporary file back to client
    streamContent(req, res, file);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:31,代码来源:WorkflowInstanceDiagramGet.java

示例11: executeImpl

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
    Map<String, Object> model = new HashMap<String, Object>();

    NodeRef nodeRef = parseRequestForNodeRef(req);

    // get request parameters
    Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
    String ruleId = templateVars.get("rule_id");

    Rule ruleToReturn = null;

    // get all rules for given nodeRef
    List<Rule> rules = ruleService.getRules(nodeRef);

    // filter by rule id
    for (Rule rule : rules)
    {
        if (rule.getNodeRef().getId().equalsIgnoreCase(ruleId))
        {
            ruleToReturn = rule;
            break;
        }
    }

    if (ruleToReturn == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find rule with id: " + ruleId);
    }

    RuleRef ruleRefToReturn = new RuleRef(ruleToReturn, fileFolderService.getFileInfo(ruleService.getOwningNodeRef(ruleToReturn)));

    model.put("ruleRef", ruleRefToReturn);

    return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:37,代码来源:RuleGet.java

示例12: executeImpl

@Override
protected Map<String, Object> executeImpl(final WebScriptRequest req, Status status, Cache cache)
{
    if (! isEnabled())
    {
        throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "QuickShare is disabled system-wide");
    }
    
    // create map of params (template vars)
    Map<String, String> params = req.getServiceMatch().getTemplateVars();
    final String sharedId = params.get("shared_id");
    if (sharedId == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "A valid sharedId must be specified !");
    }
    
    try
    {
        boolean canRead = quickShareService.canRead(sharedId);
        Map<String, Object> result = new HashMap<String, Object>();
        result.put("canRead", canRead);
        return result;            
    }
    catch (InvalidSharedIdException ex)
    {
        logger.error("Unable to find: "+sharedId);
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: "+sharedId);
    }
    catch (InvalidNodeRefException inre)
    {
        logger.error("Unable to find: "+sharedId+" ["+inre.getNodeRef()+"]");
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: "+sharedId);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:34,代码来源:ReadGet.java

示例13: executeImpl

@Override
protected Map<String, Object> executeImpl(final WebScriptRequest req, Status status, Cache cache)
{
    if (! isEnabled())
    {
        throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "QuickShare is disabled system-wide");
    }
    
    // create map of params (template vars)
    Map<String, String> params = req.getServiceMatch().getTemplateVars();
    final String sharedId = params.get("shared_id");
    if (sharedId == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "A valid sharedId must be specified !");
    }
    
    try
    {
        return quickShareService.getMetaData(sharedId);
    }
    catch (InvalidSharedIdException ex)
    {
        logger.error("Unable to find: "+sharedId);
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: "+sharedId);
    }
    catch (InvalidNodeRefException inre)
    {
        logger.error("Unable to find: "+sharedId+" ["+inre.getNodeRef()+"]");
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: "+sharedId);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:31,代码来源:QuickShareMetaDataGet.java

示例14: executeImpl

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
    if (! isEnabled())
    {
        throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "QuickShare is disabled system-wide");
    }

    // create map of params (template vars)
    Map<String, String> params = req.getServiceMatch().getTemplateVars();
    final String sharedId = params.get("shared_id");
    if (sharedId == null)
    {
        throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "A valid sharedId must be specified !");
    }

    try
    {
        NodeRef nodeRef = quickShareService.getTenantNodeRefFromSharedId(sharedId).getSecond();

        String sharedBy = (String) nodeService.getProperty(nodeRef, QuickShareModel.PROP_QSHARE_SHAREDBY);
        if (!quickShareService.canDeleteSharedLink(nodeRef, sharedBy))
        {
            throw new WebScriptException(HttpServletResponse.SC_FORBIDDEN, "Can't perform unshare action: " + sharedId);
        }
        quickShareService.unshareContent(sharedId);

        Map<String, Object> model = new HashMap<>(1);
        model.put("success", Boolean.TRUE);
        return model;
    }
    catch (InvalidSharedIdException ex)
    {
        logger.error("Unable to find: " + sharedId);
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: " + sharedId);
    }
    catch (InvalidNodeRefException inre)
    {
        logger.error("Unable to find: " + sharedId + " [" + inre.getNodeRef() + "]");
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Unable to find: " + sharedId);
    }
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:42,代码来源:UnshareContentDelete.java

示例15: executeImpl

@Override
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache)
{
    String currentUser = AuthenticationUtil.getFullyAuthenticatedUser();
    // check the current user access rights
    if (!siteService.isSiteAdmin(currentUser))
    {
        // Note: security, no message to indicate why
        throw new WebScriptException(HttpServletResponse.SC_NOT_FOUND, "Resource not found.");
    }

    // Create paging
    final ScriptPagingDetails paging = new ScriptPagingDetails(getIntParameter(req, MAX_ITEMS,
                DEFAULT_MAX_ITEMS_PER_PAGE), getIntParameter(req, SKIP_COUNT, 0));

    // request a total count of found items
    paging.setRequestTotalCountMax(Integer.MAX_VALUE);

    final List<FilterProp> filterProp = getFilterProperties(req.getParameter(NAME_FILTER));

    final List<Pair<QName, Boolean>> sortProps = new ArrayList<Pair<QName, Boolean>>();
    sortProps.add(new Pair<QName, Boolean>(ContentModel.PROP_NAME, true));

    PagingResults<SiteInfo> pagingResults = AuthenticationUtil.runAs(
                new AuthenticationUtil.RunAsWork<PagingResults<SiteInfo>>()
                {
                    public PagingResults<SiteInfo> doWork() throws Exception
                    {
                        return siteService.listSites(filterProp, sortProps, paging);
                    }
                }, AuthenticationUtil.getAdminUserName());

    List<SiteInfo> result = pagingResults.getPage();
    List<SiteState> sites = new ArrayList<SiteState>(result.size());
    for (SiteInfo info : result)
    {
        sites.add(SiteState.create(info,
                    siteService.listMembers(info.getShortName(), null, SiteModel.SITE_MANAGER, 0), currentUser,
                    nodeService, personService));
    }

    Map<String, Object> sitesData = new HashMap<String, Object>(6);

    // Site data
    sitesData.put("items", sites);
    // Paging data
    sitesData.put("count", result.size());
    sitesData.put("hasMoreItems", pagingResults.hasMoreItems());
    sitesData.put("totalItems", (pagingResults.getTotalResultCount() == null ? -1 : pagingResults.getTotalResultCount().getFirst()));
    sitesData.put("skipCount", paging.getSkipCount());
    sitesData.put("maxItems", paging.getMaxItems());
    
    // Create the model from the site and pagination data
    Map<String, Object> model = new HashMap<String, Object>(1);
    model.put("data", sitesData);

    return model;
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:58,代码来源:SiteAdminSitesGet.java


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