当前位置: 首页>>代码示例>>Java>>正文


Java UserMessage类代码示例

本文整理汇总了Java中org.lastaflute.core.message.UserMessage的典型用法代码示例。如果您正苦于以下问题:Java UserMessage类的具体用法?Java UserMessage怎么用?Java UserMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


UserMessage类属于org.lastaflute.core.message包,在下文中一共展示了UserMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: throwClientErrorByValidatorException

import org.lastaflute.core.message.UserMessage; //导入依赖的package包/类
protected void throwClientErrorByValidatorException(Object form, Set<ConstraintViolation<Object>> clientErrorSet) {
    final StringBuilder sb = new StringBuilder();
    sb.append("Client Error detected by validator: runtimeGroups="); // similar to normal validation error logging
    sb.append(Stream.of(runtimeGroups).map(tp -> {
        return tp.getSimpleName() + ".class";
    }).collect(Collectors.toList()));
    final MESSAGES messages = toUserMessages(form, clientErrorSet);
    messages.toPropertySet().forEach(property -> {
        sb.append(LF).append(" ").append(property);
        for (Iterator<UserMessage> ite = messages.silentAccessByIteratorOf(property); ite.hasNext();) {
            sb.append(LF).append("   ").append(ite.next());
        }
    });
    final String msg = sb.toString();
    throw new ClientErrorByValidatorException(msg, messages);
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:17,代码来源:ActionValidator.java

示例2: createTypeFailureActionMessage

import org.lastaflute.core.message.UserMessage; //导入依赖的package包/类
protected UserMessage createTypeFailureActionMessage(TypeFailureElement element) {
    final String propertyPath = element.getPropertyPath();
    final Class<?> propertyType = element.getPropertyType();
    final String messageKey = typeMessageMap.get(propertyType);
    final String completeMsg;
    if (messageKey != null) {
        completeMsg = findMessage(messageKey).map(message -> {
            return filterTypeFailureMessage(message, propertyPath, propertyType);
        }).orElseGet(() -> {
            return buildDefaultTypeMessage(propertyPath, propertyType);
        });
    } else {
        completeMsg = buildDefaultTypeMessage(propertyPath, propertyType);
    }
    final ValidateTypeFailure annotation = element.getAnnotation();
    return createDirectMessage(completeMsg, annotation, annotation.groups(), messageKey);
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:18,代码来源:ActionValidator.java

示例3: assertMessages

import org.lastaflute.core.message.UserMessage; //导入依赖的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

示例4: setupItemMessages

import org.lastaflute.core.message.UserMessage; //导入依赖的package包/类
protected void setupItemMessages(ExceptionMessageBuilder br, UserMessages messages) {
    br.addItem("Messages");
    final Set<String> propertySet = messages.toPropertySet();
    for (String property : propertySet) {
        br.addElement(property);
        for (Iterator<UserMessage> ite = messages.accessByIteratorOf(property); ite.hasNext();) {
            br.addElement("  " + ite.next());
        }
    }
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:11,代码来源:ResponseBeanValidator.java

示例5: handleValidationErrorException

import org.lastaflute.core.message.UserMessage; //导入依赖的package包/类
protected ActionResponse handleValidationErrorException(ValidationErrorException cause) {
    final UserMessages messages = cause.getMessages();
    assertValidationErrorMessagesExists(messages, cause);
    if (logger.isDebugEnabled()) {
        final StringBuilder sb = new StringBuilder();
        sb.append(LF).append("_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/");
        sb.append(LF).append("[Validation Error]: runtimeGroups=");
        sb.append(Stream.of(cause.getRuntimeGroups()).map(tp -> {
            return tp.getSimpleName() + ".class";
        }).collect(Collectors.toList()));
        sb.append(" #").append(Integer.toHexString(cause.hashCode()));
        messages.toPropertySet().forEach(property -> {
            sb.append(LF).append(" ").append(property);
            for (Iterator<UserMessage> ite = messages.silentAccessByIteratorOf(property); ite.hasNext();) {
                sb.append(LF).append("   ").append(ite.next());
            }
        });
        final Throwable nested = cause.getCause();
        if (nested != null) { // e.g. from remote api
            sb.append(LF).append(" - - - - - - - - - -");
            sb.append(LF).append(" caused by ").append(nested.getClass().getSimpleName()).append(":");
            sb.append(LF).append(nested.getMessage());
        }
        sb.append(LF).append("_/_/_/_/_/_/_/_/_/_/");
        logger.debug(sb.toString());
    }
    requestManager.errors().saveMessages(messages); // also API can use it
    runtime.manageValidationErrors(messages); // reflect to runtime
    runtime.manageFailureCause(cause); // also cause
    final VaErrorHook errorHook = cause.getErrorHook();
    final ActionResponse response = errorHook.hook(); // failure hook here if API
    if (response == null) {
        throw new IllegalStateException("The handler for validation error cannot return null: " + errorHook, cause);
    }
    response.getAfterTxCommitHook().ifPresent(hook -> {
        throw new IllegalStateException("Validation error always rollbacks transaction but tx-commit hook specified:" + hook);
    });
    return response;
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:40,代码来源:GodHandableAction.java

示例6: toApplicationMessageList

import org.lastaflute.core.message.UserMessage; //导入依赖的package包/类
protected List<LaApplicationMessage> toApplicationMessageList(UserMessages messages) {
    final List<LaApplicationMessage> convertedList = new ArrayList<LaApplicationMessage>(messages.size());
    for (String property : messages.toPropertySet()) {
        for (Iterator<UserMessage> ite = messages.accessByIteratorOf(property); ite.hasNext();) {
            final UserMessage message = ite.next();
            verifyResourceMessage(messages, message);
            convertedList.add(toApplicationMessage(property, message));
        }
    }
    return convertedList;
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:12,代码来源:MessagingApplicationException.java

示例7: test_toUserMessages

import org.lastaflute.core.message.UserMessage; //导入依赖的package包/类
public void test_toUserMessages() throws Exception {
    // ## Arrange ##
    ActionValidator<UserMessages> validator = createValidator();
    MockForm form = new MockForm();
    Set<ConstraintViolation<Object>> vioSet = new HashSet<ConstraintViolation<Object>>();
    vioSet.add(createViolation("sea"));
    vioSet.add(createViolation("land.oneman"));
    vioSet.add(createViolation("land.minio"));
    vioSet.add(createViolation("piari"));
    vioSet.add(createViolation("piari[0].dstore"));
    vioSet.add(createViolation("piari[2].dstore"));
    vioSet.add(createViolation("piari[2].plaza"));
    vioSet.add(createViolation("piari[3].plaza"));
    vioSet.add(createViolation("piari[5].dstore"));

    // ## Act ##
    UserMessages messages = validator.toUserMessages(form, vioSet);

    // ## Assert ##
    Set<String> propertySet = messages.toPropertySet();
    assertHasAnyElement(propertySet);
    log(propertySet);
    assertEquals(vioSet.size(), propertySet.size());
    List<UserMessage> messageList = new ArrayList<UserMessage>();
    for (String property : propertySet) {
        for (Iterator<UserMessage> iterator = messages.accessByIteratorOf(property); iterator.hasNext();) {
            messageList.add(iterator.next());
        }
    }
    for (UserMessage message : messageList) {
        log(message);
    }
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:34,代码来源:ActionValidatorTest.java

示例8: test_hasMessageOf

import org.lastaflute.core.message.UserMessage; //导入依赖的package包/类
public void test_hasMessageOf() throws Exception {
    // ## Arrange ##
    UserMessages messages = new UserMessages();
    assertFalse(messages.hasMessageOf("sea"));
    UserMessage message = new UserMessage("dockside", "over");
    assertFalse(messages.isAccessed());
    messages.add("sea", message);

    // ## Act ##
    // ## Assert ##
    assertTrue(messages.hasMessageOf("sea"));
    assertFalse(messages.hasMessageOf("land"));
    assertFalse(messages.isAccessed());
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:15,代码来源:ActionMessagesTest.java

示例9: test_hasMessageOf_key

import org.lastaflute.core.message.UserMessage; //导入依赖的package包/类
public void test_hasMessageOf_key() throws Exception {
    // ## Arrange ##
    UserMessages messages = new UserMessages();
    assertFalse(messages.hasMessageOf("sea"));
    UserMessage message = new UserMessage("dockside", "over");
    assertFalse(messages.isAccessed());
    messages.add("sea", message);

    // ## Act ##
    // ## Assert ##
    assertTrue(messages.hasMessageOf("sea", "dockside"));
    assertFalse(messages.hasMessageOf("sea", "hangar"));
    assertFalse(messages.hasMessageOf("land", "dockside"));
    assertFalse(messages.isAccessed());
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:16,代码来源:ActionMessagesTest.java

示例10: createDirectMessage

import org.lastaflute.core.message.UserMessage; //导入依赖的package包/类
protected UserMessage createDirectMessage(String msg, Annotation annotation, Class<?>[] groups, String messageKey) {
    return UserMessage.asDirectMessage(msg, annotation, groups, unbraceDirectMessageKey(messageKey));
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:4,代码来源:ActionValidator.java

示例11: prepareUserMessages

import org.lastaflute.core.message.UserMessage; //导入依赖的package包/类
protected UserMessages prepareUserMessages(String property, String messageKey, Object[] args) {
    final UserMessages messages = newUserMessages();
    messages.add(property, new UserMessage(messageKey, args));
    return messages;
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:6,代码来源:ScopedMessageHandler.java

示例12: verifyResourceMessage

import org.lastaflute.core.message.UserMessage; //导入依赖的package包/类
protected void verifyResourceMessage(UserMessages messages, UserMessage message) {
    // client error can be non-resource message by e.g. validator
    //if (!message.isResource()) {
    //    throw new IllegalArgumentException("Not allowed the non-resource message: " + message + " in " + messages);
    //}
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:7,代码来源:MessagingClientErrorException.java

示例13: verifyResourceMessage

import org.lastaflute.core.message.UserMessage; //导入依赖的package包/类
protected void verifyResourceMessage(UserMessages messages, UserMessage message) {
    if (!message.isResource()) {
        throw new IllegalArgumentException("Not allowed the non-resource message: " + message + " in " + messages);
    }
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:6,代码来源:MessagingApplicationException.java

示例14: toApplicationMessage

import org.lastaflute.core.message.UserMessage; //导入依赖的package包/类
protected LaApplicationMessage toApplicationMessage(String property, UserMessage message) {
    return new LaApplicationMessage(property, message.getMessageKey(), message.getValues());
}
 
开发者ID:lastaflute,项目名称:lastaflute,代码行数:4,代码来源:MessagingApplicationException.java

示例15: addConstraintsAssertFalseMessage

import org.lastaflute.core.message.UserMessage; //导入依赖的package包/类
/**
 * Add the created action message for the key 'constraints.AssertFalse.message' with parameters.
 * <pre>
 * message: must be false
 * comment: ---------------
 * </pre>
 * @param property The property name for the message. (NotNull)
 * @return this. (NotNull)
 */
public HarborMessages addConstraintsAssertFalseMessage(String property) {
    assertPropertyNotNull(property);
    add(property, new UserMessage(CONSTRAINTS_AssertFalse_MESSAGE));
    return this;
}
 
开发者ID:lastaflute,项目名称:lastaflute-example-harbor,代码行数:15,代码来源:HarborMessages.java


注:本文中的org.lastaflute.core.message.UserMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。