本文整理汇总了Java中org.springframework.extensions.webscripts.Status.setCode方法的典型用法代码示例。如果您正苦于以下问题:Java Status.setCode方法的具体用法?Java Status.setCode怎么用?Java Status.setCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.extensions.webscripts.Status
的用法示例。
在下文中一共展示了Status.setCode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeImpl
import org.springframework.extensions.webscripts.Status; //导入方法依赖的package包/类
@Override
protected Map<String, Object> executeImpl(WebScriptRequest req,
Status status, Cache cache)
{
Map<String, String> templateVars = req.getServiceMatch().getTemplateVars();
// Site is optional
SiteInfo site = null;
String siteName = templateVars.get("site");
if (siteName != null)
{
site = siteService.getSite(siteName);
// MNT-3053 fix, siteName was provided in request but it doesn't exists or user has no permissions to access it.
if (site == null)
{
status.setCode(HttpServletResponse.SC_NOT_FOUND, "Site '" + siteName + "' does not exist or user has no permissions to access it.");
return null;
}
}
return executeImpl(site, null, req, null, status, cache);
}
示例2: setExceptionResponse
import org.springframework.extensions.webscripts.Status; //导入方法依赖的package包/类
private void setExceptionResponse(WebScriptRequest req, Status responseStatus, String responseMessage, int statusCode, Exception e)
{
String message = responseMessage + req;
if (logger.isDebugEnabled())
{
logger.warn(message, e);
}
else
{
logger.warn(message);
}
responseStatus.setCode(statusCode, message);
responseStatus.setException(e);
}
示例3: 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;
}
}
示例4: 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;
}
示例5: executeImpl
import org.springframework.extensions.webscripts.Status; //导入方法依赖的package包/类
@Override
protected Map<String, Object> executeImpl(SiteInfo site, String eventName,
WebScriptRequest req, JSONObject json, Status status, Cache cache)
{
CalendarEntry entry = calendarService.getCalendarEntry(
site.getShortName(), eventName);
if (entry == null)
{
status.setCode(Status.STATUS_NOT_FOUND);
return null;
}
// Special case for "deleting" an instance of a recurring event
if (req.getParameter("date") != null && entry.getRecurrenceRule() != null)
{
// Have an ignored event generated
createIgnoreEvent(req, entry);
// Mark as ignored
status.setCode(Status.STATUS_NO_CONTENT, "Recurring entry ignored");
return null;
}
// Delete the calendar entry
calendarService.deleteCalendarEntry(entry);
// Record this in the activity feed
addActivityEntry("deleted", entry, site, req, json);
// All done
status.setCode(Status.STATUS_NO_CONTENT, "Entry deleted");
return null;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: executeImpl
import org.springframework.extensions.webscripts.Status; //导入方法依赖的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;
}
示例10: executeImpl
import org.springframework.extensions.webscripts.Status; //导入方法依赖的package包/类
@Override
protected Map<String, Object> executeImpl(SiteInfo site, String linkName,
WebScriptRequest req, JSONObject json, Status status, Cache cache)
{
final ResourceBundle rb = getResources();
Map<String, Object> model = new HashMap<String, Object>();
// Get the new link details from the JSON
String title;
String description;
String url;
boolean internal;
List<String> tags;
// Fetch the main properties
title = getOrNull(json, "title");
description = getOrNull(json, "description");
url = getOrNull(json, "url");
// Handle internal / not internal
internal = json.containsKey("internal");
// Do the tags
tags = getTags(json);
// Create the link
LinkInfo link;
try
{
link = linksService.createLink(site.getShortName(), title, description, url, internal);
}
catch (AccessDeniedException e)
{
String message = "You don't have permission to create a link";
status.setCode(Status.STATUS_FORBIDDEN);
status.setMessage(message);
model.put(PARAM_MESSAGE, rb.getString(MSG_ACCESS_DENIED));
return model;
}
// Set the tags if required
if (tags != null && tags.size() > 0)
{
link.getTags().addAll(tags);
linksService.updateLink(link);
}
// Generate an activity for the change
addActivityEntry("created", link, site, req, json);
// Build the model
model.put(PARAM_MESSAGE, link.getSystemName()); // Really!
model.put(PARAM_ITEM, renderLink(link));
model.put("node", link.getNodeRef());
model.put("link", link);
model.put("site", site);
model.put("siteId", site.getShortName());
// All done
return model;
}