當前位置: 首頁>>代碼示例>>Java>>正文


Java Controller.badRequest方法代碼示例

本文整理匯總了Java中play.mvc.Controller.badRequest方法的典型用法代碼示例。如果您正苦於以下問題:Java Controller.badRequest方法的具體用法?Java Controller.badRequest怎麽用?Java Controller.badRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在play.mvc.Controller的用法示例。


在下文中一共展示了Controller.badRequest方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: downloadFileAttachment

import play.mvc.Controller; //導入方法依賴的package包/類
/**
 * This method is to be integrated within a controller.<br/>
 * It looks for the specified attachment and returns it if the user is
 * allowed to access it.
 * 
 * @param attachmentId
 *            the id of an attachment
 * @param attachmentManagerPlugin
 *            the service which is managing attachments
 * @param sessionManagerPlugin
 *            the service which is managing user sessions
 * @return the attachment as a stream
 */
public static Result downloadFileAttachment(Long attachmentId, IAttachmentManagerPlugin attachmentManagerPlugin,
        IUserSessionManagerPlugin sessionManagerPlugin) {
    @SuppressWarnings("unchecked")
    Set<Long> allowedIds = (Set<Long>) Cache
            .get(IFrameworkConstants.ATTACHMENT_READ_AUTHZ_CACHE_PREFIX + sessionManagerPlugin.getUserSessionId(Controller.ctx()));
    if (allowedIds != null && allowedIds.contains(attachmentId)) {
        try {
            Attachment attachment = attachmentManagerPlugin.getAttachmentFromId(attachmentId);

            if (attachment.mimeType.equals(FileAttachmentHelper.FileType.URL.name())) {
                return Controller.redirect(attachment.path);
            } else {
                Controller.response().setHeader("Content-Disposition", "attachment; filename=\"" + attachment.name + "\"");
                return Controller.ok(attachmentManagerPlugin.getAttachmentContent(attachmentId));
            }
        } catch (IOException e) {
            log.error("Error while retreiving the attachment content for " + attachmentId);
            return Controller.badRequest();
        }
    }
    return Controller.badRequest();
}
 
開發者ID:theAgileFactory,項目名稱:app-framework,代碼行數:36,代碼來源:FileAttachmentHelper.java

示例2: deleteFileAttachment

import play.mvc.Controller; //導入方法依賴的package包/類
/**
 * This method is to be integrated within a controller.<br/>
 * It looks for the specified attachment and delete it if the user is
 * allowed to erase it.<br/>
 * It is to be called by an AJAX GET with a single attribute : the id of the
 * attachment.
 *
 * @param attachmentId
 *            the id of an attachment
 * @param attachmentManagerPlugin
 *            the service which is managing attachments
 * @param sessionManagerPlugin
 *            the service which is managing user sessions
 * @return the result
 */
public static Result deleteFileAttachment(Long attachmentId, IAttachmentManagerPlugin attachmentManagerPlugin,
        IUserSessionManagerPlugin sessionManagerPlugin) {
    @SuppressWarnings("unchecked")
    Set<Long> allowedIds = (Set<Long>) Cache
            .get(IFrameworkConstants.ATTACHMENT_WRITE_AUTHZ_CACHE_PREFIX + sessionManagerPlugin.getUserSessionId(Controller.ctx()));
    if (allowedIds != null && allowedIds.contains(attachmentId)) {
        try {
            attachmentManagerPlugin.deleteAttachment(attachmentId);
            return Controller.ok();
        } catch (IOException e) {
            log.error("Error while deleting the attachment content for " + attachmentId);
            return Controller.badRequest();
        }
    }
    return Controller.badRequest();
}
 
開發者ID:theAgileFactory,項目名稱:app-framework,代碼行數:32,代碼來源:FileAttachmentHelper.java

示例3: handle

import play.mvc.Controller; //導入方法依賴的package包/類
public Result handle(Request request) {
    JsonNode json = request.body().asJson();
    String requestType = json.get("requestType").asText();
    switch (RequestType.valueOf(requestType)) {
    case CONFIG:
        return getConfigResponse();
    case INIT:
        return getInitialValueResponse(json);
    case SEARCH:
        return getSearchResponse(json);
    }
    return Controller.badRequest();
}
 
開發者ID:theAgileFactory,項目名稱:app-framework,代碼行數:14,代碼來源:PickerHandler.java

示例4: displayAccessForbidden

import play.mvc.Controller; //導入方法依賴的package包/類
@Override
public Result displayAccessForbidden() {
    return Controller.badRequest(views.html.error.access_forbidden.render(getMessagesPlugins().get("forbidden.access.title")));
}
 
開發者ID:theAgileFactory,項目名稱:maf-desktop-app,代碼行數:5,代碼來源:SecurityServiceImpl.java


注:本文中的play.mvc.Controller.badRequest方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。