当前位置: 首页>>代码示例>>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;未经允许,请勿转载。