本文整理匯總了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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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;
}