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


Java UserMessages類代碼示例

本文整理匯總了Java中org.lastaflute.core.message.UserMessages的典型用法代碼示例。如果您正苦於以下問題:Java UserMessages類的具體用法?Java UserMessages怎麽用?Java UserMessages使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


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

示例1: registerActionMessage

import org.lastaflute.core.message.UserMessages; //導入依賴的package包/類
protected void registerActionMessage(UserMessages messages, ConstraintViolation<Object> vio) {
    final String propertyPath = extractPropertyPath(vio);
    final String plainMessage = filterMessageItem(extractMessage(vio), propertyPath);
    final String delimiter = MESSAGE_HINT_DELIMITER;
    final String messageItself;
    final String messageKey;
    if (plainMessage.contains(delimiter)) { // basically here
        messageItself = Srl.substringFirstRear(plainMessage, delimiter);
        messageKey = Srl.substringFirstFront(plainMessage, delimiter);
    } else { // just in case
        messageItself = plainMessage;
        messageKey = null;
    }
    final ConstraintDescriptor<?> descriptor = vio.getConstraintDescriptor();
    final Annotation annotation = descriptor.getAnnotation();
    final Set<Class<?>> groupSet = descriptor.getGroups();
    final Class<?>[] groups = groupSet.toArray(new Class<?>[groupSet.size()]);
    messages.add(propertyPath, createDirectMessage(messageItself, annotation, groups, messageKey));
}
 
開發者ID:lastaflute,項目名稱:lastaflute,代碼行數:20,代碼來源:ActionValidator.java

示例2: doVerifyToken

import org.lastaflute.core.message.UserMessages; //導入依賴的package包/類
protected <MESSAGES extends UserMessages> void doVerifyToken(Class<?> groupType, TokenErrorHook errorHook, boolean keep) {
    assertArgumentNotNull("groupType", groupType);
    assertArgumentNotNull("errorHook", errorHook);
    checkVerifyTokenAfterValidatorCall(); // precisely unneeded if keep, but coherence
    final boolean matched;
    if (keep) { // no reset (intermediate request)
        matched = determineToken(groupType);
    } else { // mainly here (finish)
        matched = determineTokenWithReset(groupType);
    }
    if (!matched) {
        saveDoubleSubmittedMark();
        throwDoubleSubmittedRequestException(groupType, errorHook);
    } else {
        saveSingleSubmittedMark(); // means verified  for e.g. UnitTest
    }
}
 
開發者ID:lastaflute,項目名稱:lastaflute,代碼行數:18,代碼來源:SimpleDoubleSubmitManager.java

示例3: throwDoubleSubmittedRequestException

import org.lastaflute.core.message.UserMessages; //導入依賴的package包/類
protected <MESSAGES extends UserMessages> String throwDoubleSubmittedRequestException(Class<?> groupType, TokenErrorHook errorHook) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("The request was born from double submit.");
    br.addItem("Advice");
    br.addElement("Double submit by user operation or no saved token.");
    br.addElement("Default scope of token is action type");
    br.addElement("so SAVE and VERIFY should be in same action.");
    br.addItem("Requested Action");
    br.addElement(LaActionRuntimeUtil.hasActionRuntime() ? LaActionRuntimeUtil.getActionRuntime() : null);
    br.addItem("Token Group");
    br.addElement(groupType.getName());
    br.addItem("Requested Token");
    br.addElement(getRequestedToken());
    br.addItem("Saved Token");
    br.addElement(getSessionTokenMap());
    final String msg = br.buildExceptionMessage();
    final String messageKey = getDoubleSubmitMessageKey();
    throw new DoubleSubmittedRequestException(msg, () -> errorHook.hook(), UserMessages.createAsOneGlobal(messageKey));
}
 
開發者ID:lastaflute,項目名稱:lastaflute,代碼行數:20,代碼來源:SimpleDoubleSubmitManager.java

示例4: throwTooLongBoundarySizeException

import org.lastaflute.core.message.UserMessages; //導入依賴的package包/類
protected void throwTooLongBoundarySizeException(String contentType, int boundarySize, int limitSize) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Too long boundary size so treats it as 404.");
    br.addItem("Advice");
    br.addElement("Against for JVN14876762.");
    br.addElement("Boundary size is limited by Framework.");
    br.addElement("Too long boundary is treated as 404 because it's thought of as attack.");
    br.addElement("");
    br.addElement("While, you can override the boundary limit size");
    br.addElement(" in " + HarborMultipartRequestHandler.class.getSimpleName() + ".");
    br.addItem("Content Type");
    br.addElement(contentType);
    br.addItem("Boundary Size");
    br.addElement(boundarySize);
    br.addItem("Limit Size");
    br.addElement(limitSize);
    final String msg = br.buildExceptionMessage();
    throw new Forced404NotFoundException(msg, UserMessages.empty()); // heavy attack!? so give no page to tell wasted action
}
 
開發者ID:lastaflute,項目名稱:lastaflute-example-harbor,代碼行數:20,代碼來源:HarborMultipartRequestHandler.java

示例5: ValidationErrorException

import org.lastaflute.core.message.UserMessages; //導入依賴的package包/類
public ValidationErrorException(Class<?>[] runtimeGroups, UserMessages messages, VaErrorHook errorHook, Throwable cause) {
    super("Validation Error for user input: " + messages, cause);
    if (runtimeGroups == null) {
        throw new IllegalArgumentException("The argument 'runtimeGroups' should not be null.");
    }
    if (messages == null) {
        throw new IllegalArgumentException("The argument 'messages' should not be null.");
    }
    if (errorHook == null) {
        throw new IllegalArgumentException("The argument 'errorHandler' should not be null.");
    }
    this.runtimeGroups = runtimeGroups;
    this.messages = messages;
    this.errorHook = errorHook;
}
 
開發者ID:lastaflute,項目名稱:lastaflute,代碼行數:16,代碼來源:ValidationErrorException.java

示例6: doNew400

import org.lastaflute.core.message.UserMessages; //導入依賴的package包/類
protected RuntimeException doNew400(String debugMsg, ForcedClientErrorOpCall opLambda) {
    final ForcedClientErrorOption option = createClientErrorOption(opLambda);
    final UserMessages messages = option.getMessages().orElseGet(() -> UserMessages.empty());
    return option.getCause().map(cause -> {
        return new Forced400BadRequestException(debugMsg, messages, cause);
    }).orElseGet(() -> {
        return new Forced400BadRequestException(debugMsg, messages);
    });
}
 
開發者ID:lastaflute,項目名稱:lastaflute,代碼行數:10,代碼來源:SimpleResponseManager.java

示例7: doNew403

import org.lastaflute.core.message.UserMessages; //導入依賴的package包/類
protected RuntimeException doNew403(String debugMsg, ForcedClientErrorOpCall opLambda) {
    final ForcedClientErrorOption option = createClientErrorOption(opLambda);
    final UserMessages messages = option.getMessages().orElseGet(() -> UserMessages.empty());
    return option.getCause().map(cause -> {
        return new Forced403ForbiddenException(debugMsg, messages, cause);
    }).orElseGet(() -> {
        return new Forced403ForbiddenException(debugMsg, messages);
    });
}
 
開發者ID:lastaflute,項目名稱:lastaflute,代碼行數:10,代碼來源:SimpleResponseManager.java

示例8: doNew404

import org.lastaflute.core.message.UserMessages; //導入依賴的package包/類
protected RuntimeException doNew404(String debugMsg, ForcedClientErrorOpCall opLambda) {
    final ForcedClientErrorOption option = createClientErrorOption(opLambda);
    final UserMessages messages = option.getMessages().orElseGet(() -> UserMessages.empty());
    return option.getCause().map(cause -> {
        return new Forced404NotFoundException(debugMsg, messages, cause);
    }).orElseGet(() -> {
        return new Forced404NotFoundException(debugMsg, messages);
    });
}
 
開發者ID:lastaflute,項目名稱:lastaflute,代碼行數:10,代碼來源:SimpleResponseManager.java

示例9: prepareClientExceptionThrownPart

import org.lastaflute.core.message.UserMessages; //導入依賴的package包/類
protected FaicliFailureErrorPart prepareClientExceptionThrownPart(ApiFailureResource resource, RuntimeException cause,
        FaicliUnifiedFailureResult result) {
    final Map<String, Object> data = new LinkedHashMap<String, Object>();
    data.put("type", cause.getClass().getName());
    data.put("message", buildClientExceptionMessage(cause));
    return new FaicliFailureErrorPart(UserMessages.GLOBAL, "THROWN_EXCEPTION", data);
}
 
開發者ID:lastaflute,項目名稱:lastaflute,代碼行數:8,代碼來源:TypicalFaicliApiFailureHook.java

示例10: doRecoverMessages

import org.lastaflute.core.message.UserMessages; //導入依賴的package包/類
protected Map<String, List<String>> doRecoverMessages(ApiFailureResource resource, RuntimeException cause, String messageKey) {
    final RequestManager requestManager = resource.getRequestManager();
    final String message = requestManager.getMessageManager().getMessage(requestManager.getUserLocale(), messageKey);
    final Map<String, List<String>> map = DfCollectionUtil.newLinkedHashMap();
    map.put(UserMessages.GLOBAL, DfCollectionUtil.newArrayList(message));
    return Collections.unmodifiableMap(map);
}
 
開發者ID:lastaflute,項目名稱:lastaflute,代碼行數:8,代碼來源:TypicalFaicliApiFailureHook.java

示例11: prepareClientExceptionThrownPart

import org.lastaflute.core.message.UserMessages; //導入依賴的package包/類
protected FaihyFailureErrorPart prepareClientExceptionThrownPart(ApiFailureResource resource, RuntimeException cause,
        FaihyUnifiedFailureResult result) {
    final Map<String, Object> data = new LinkedHashMap<String, Object>();
    data.put("type", cause.getClass().getName());
    data.put("message", buildClientExceptionMessage(cause));
    final String serverManaged = buildClientExceptionThrownServerManaged();
    return new FaihyFailureErrorPart(UserMessages.GLOBAL, "THROWN_EXCEPTION", data, serverManaged);
}
 
開發者ID:lastaflute,項目名稱:lastaflute,代碼行數:9,代碼來源:TypicalFaihyApiFailureHook.java

示例12: assertMessages

import org.lastaflute.core.message.UserMessages; //導入依賴的package包/類
protected void assertMessages(UserMessages messages) {
    if (messages == null) {
        throw new IllegalArgumentException("The argument 'messages' should not be null.");
    }
    // client error does not require message
    //if (messages.isEmpty()) {
    //    throw new IllegalArgumentException("The messages should not be empty: " + messages);
    //}
    for (Iterator<UserMessage> ite = messages.silentAccessByFlatIterator(); ite.hasNext();) {
        final UserMessage message = ite.next();
        verifyResourceMessage(messages, message);
    }
}
 
開發者ID:lastaflute,項目名稱:lastaflute,代碼行數:14,代碼來源:MessagingClientErrorException.java

示例13: dispatchApiClientErrorException

import org.lastaflute.core.message.UserMessages; //導入依賴的package包/類
protected void dispatchApiClientErrorException(ActionRuntime runtime, ActionResponseReflector reflector,
        RequestClientErrorException cause) {
    if (isAlreadyCommitted()) { // just in case
        return; // can do nothing
    }
    final OptionalThing<UserMessages> optMessages = findClientErrorMessages(cause);
    final ApiFailureResource resource = createApiFailureResource(runtime, optMessages, cause);
    getApiManager().handleClientException(resource, cause).ifPresent(apiRes -> {
        if (!apiRes.getHttpStatus().isPresent()) { // no specified
            apiRes.httpStatus(cause.getErrorStatus()); // use thrown status
        }
        reflector.reflect(apiRes).getJourneyProvider().bonVoyage(); // always exists if API response
    });
    runtime.clearDisplayData(); // remove (possible) large data just in case
}
 
開發者ID:lastaflute,項目名稱:lastaflute,代碼行數:16,代碼來源:ActionCoinsHelper.java

示例14: findClientErrorMessages

import org.lastaflute.core.message.UserMessages; //導入依賴的package包/類
protected OptionalThing<UserMessages> findClientErrorMessages(RequestClientErrorException cause) {
    final OptionalThing<UserMessages> optMessages;
    if (cause instanceof MessagingClientErrorException) {
        final UserMessages messages = ((MessagingClientErrorException) cause).getMessages();
        optMessages = !messages.isEmpty() ? OptionalThing.of(messages) : OptionalThing.empty();
    } else {
        optMessages = OptionalThing.empty();
    }
    return optMessages;
}
 
開發者ID:lastaflute,項目名稱:lastaflute,代碼行數:11,代碼來源:ActionCoinsHelper.java

示例15: buildValidationErrorMessage

import org.lastaflute.core.message.UserMessages; //導入依賴的package包/類
@Override
protected String buildValidationErrorMessage(Object bean, Consumer<ExceptionMessageBuilder> locationBuilder, UserMessages messages) {
    final ExceptionMessageBuilder br = new ExceptionMessageBuilder();
    br.addNotice("Validation error for the JSON response.");
    br.addItem("Advice");
    br.addElement("Make sure your JSON bean property values.");
    br.addElement("For example:");
    br.addElement("  public class SeaBean {");
    br.addElement("      @Required");
    br.addElement("      public String dockside;");
    br.addElement("  }");
    br.addElement("  (x):");
    br.addElement("    public class SeaAction {");
    br.addElement("        @Execute");
    br.addElement("        public JsonResponse<SeaBean> index() {");
    br.addElement("            SeaBean bean = new SeaBean();");
    br.addElement("            return asJson(bean); // *Bad");
    br.addElement("        }");
    br.addElement("    }");
    br.addElement("  (o):");
    br.addElement("    public class SeaAction {");
    br.addElement("        @Execute");
    br.addElement("        public JsonResponse<SeaBean> index() {");
    br.addElement("            SeaBean bean = new SeaBean();");
    br.addElement("            bean.dockside = \"overthewaves\"; // Good");
    br.addElement("            return asJson(bean);");
    br.addElement("        }");
    br.addElement("    }");
    br.addItem("Action");
    br.addElement(actionExp);
    locationBuilder.accept(br); // basically do nothing when JSON
    setupItemValidatedBean(br, bean);
    setupItemMessages(br, messages);
    return br.buildExceptionMessage();
}
 
開發者ID:lastaflute,項目名稱:lastaflute,代碼行數:36,代碼來源:ResponseJsonBeanValidator.java


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