本文整理汇总了Java中org.springframework.extensions.webscripts.Status.setRedirect方法的典型用法代码示例。如果您正苦于以下问题:Java Status.setRedirect方法的具体用法?Java Status.setRedirect怎么用?Java Status.setRedirect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.extensions.webscripts.Status
的用法示例。
在下文中一共展示了Status.setRedirect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeImpl
import org.springframework.extensions.webscripts.Status; //导入方法依赖的package包/类
protected Map<String, Object> executeImpl(WebScriptRequest req, Status status)
{
// extract username and password
String username = req.getParameter("u");
if (username == null || username.length() == 0)
{
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Username not specified");
}
String password = req.getParameter("pw");
if (password == null)
{
throw new WebScriptException(HttpServletResponse.SC_BAD_REQUEST, "Password not specified");
}
try
{
return login(username, password);
}
catch(WebScriptException e)
{
status.setCode(e.getStatus());
status.setMessage(e.getMessage());
status.setRedirect(true);
return null;
}
}
示例2: buildModel
import org.springframework.extensions.webscripts.Status; //导入方法依赖的package包/类
@Override
protected Map<String, Object> buildModel(ReplicationModelBuilder modelBuilder,
WebScriptRequest req, Status status, Cache cache)
{
// Which definition did they ask for?
String replicationDefinitionName =
req.getServiceMatch().getTemplateVars().get("replication_definition_name");
ReplicationDefinition replicationDefinition =
replicationService.loadReplicationDefinition(replicationDefinitionName);
// Does it exist?
if(replicationDefinition == null) {
throw new WebScriptException(
Status.STATUS_NOT_FOUND,
"No Replication Definition found with that name"
);
}
// Delete it
replicationService.deleteReplicationDefinition(replicationDefinition);
// Report that we have deleted it
status.setCode(Status.STATUS_NO_CONTENT);
status.setMessage("Replication Definition deleted");
status.setRedirect(true);
return null;
}
示例3: executeImpl
import org.springframework.extensions.webscripts.Status; //导入方法依赖的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;
}
示例4: executeImpl
import org.springframework.extensions.webscripts.Status; //导入方法依赖的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;
}
示例5: buildModel
import org.springframework.extensions.webscripts.Status; //导入方法依赖的package包/类
@Override
protected Map<String, Object> buildModel(
RunningActionModelBuilder modelBuilder, WebScriptRequest req,
Status status, Cache cache) {
// Which action did they ask for?
String actionTrackingId =
req.getServiceMatch().getTemplateVars().get("action_tracking_id");
// Check it exists
ExecutionSummary action =
getSummaryFromKey(actionTrackingId);
if(action == null) {
throw new WebScriptException(
Status.STATUS_NOT_FOUND,
"No Running Action found with that tracking id"
);
}
ExecutionDetails details =
actionTrackingService.getExecutionDetails(action);
if(details == null) {
throw new WebScriptException(
Status.STATUS_NOT_FOUND,
"No Running Action found with that tracking id"
);
}
// Request the cancel
actionTrackingService.requestActionCancellation(action);
// Report it as having been cancelled
status.setCode(Status.STATUS_NO_CONTENT);
status.setMessage("Action cancellation requested");
status.setRedirect(true);
return null;
}