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


Java ErrorList类代码示例

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


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

示例1: saveRecipientPreferences

import org.kuali.rice.kcb.exception.ErrorList; //导入依赖的package包/类
/**
 * @see org.kuali.rice.kcb.service.RecipientPreferenceService#saveRecipientPreferences(java.lang.String, java.util.HashMap, org.kuali.rice.kcb.deliverer.MessageDeliverer)
 */
public void saveRecipientPreferences(String recipientId, HashMap<String, String> prefs, MessageDeliverer deliverer) throws ErrorList {
    deliverer.validatePreferenceValues(prefs);         
    
    for (Map.Entry<String, String> entry: prefs.entrySet()) {
       String prop = entry.getKey();
       String value = entry.getValue();
           
       // We need to check if this property is already set
       // for the user by checking doing a unique key query...if
       // it already exists, update, otherwise add it 
       RecipientPreference currentPreference = getRecipientPreference(recipientId, prop);
       if (currentPreference != null) {
          currentPreference.setRecipientId(recipientId);
          currentPreference.setProperty(prop);
          currentPreference.setValue(value);
          dataObjectService.save(currentPreference);
       } else {
          RecipientPreference recipientPreference = new RecipientPreference();
          recipientPreference.setRecipientId(recipientId);
          recipientPreference.setProperty(prop);
          recipientPreference.setValue(value);
          dataObjectService.save(recipientPreference);
       }
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:29,代码来源:RecipientPreferenceServiceImpl.java

示例2: validatePreferenceValues

import org.kuali.rice.kcb.exception.ErrorList; //导入依赖的package包/类
/**
 * @see org.kuali.rice.kcb.deliverer.MessageDeliverer#validatePreferenceValues(java.util.HashMap)
 */
public void validatePreferenceValues(HashMap prefs) throws ErrorList {
    boolean error = false;
    ErrorList errorList = new ErrorList();

    if (!prefs.containsKey(getName()+"."+MOBILE_NUMBER)) {
        errorList.addError("Mobile Phone Number is a required field.");
        error = true;
    } else {
        String mobileNumber = (String) prefs.get(getName()+"."+MOBILE_NUMBER);
        if(StringUtils.isBlank(mobileNumber)) {
            errorList.addError("Mobile Phone Number is a required.");
            error = true;
        }
    }
    if (error) throw errorList;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:20,代码来源:SMSMessageDeliverer.java

示例3: validatePreferenceValues

import org.kuali.rice.kcb.exception.ErrorList; //导入依赖的package包/类
/**
 * @see org.kuali.rice.kcb.deliverer.MessageDeliverer#validatePreferenceValues(java.util.HashMap)
 */
public void validatePreferenceValues(HashMap prefs) throws ErrorList {
    boolean error = false;
    ErrorList errorList = new ErrorList();

    if (!prefs.containsKey(getName()+"."+SCREEN_NAME)) {
        errorList.addError("AIM Screen Name is a required field.");
        error = true;
    } else {
        String screenName = (String) prefs.get(getName()+"."+SCREEN_NAME);
        if(StringUtils.isBlank(screenName)) {
            errorList.addError("AIM Screen Name is a required.");
            error = true;
        }
    }
    if (error) throw errorList;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:20,代码来源:AOLInstantMessageDeliverer.java

示例4: validatePreferenceValues

import org.kuali.rice.kcb.exception.ErrorList; //导入依赖的package包/类
/**
 * @see org.kuali.rice.kcb.deliverer.MessageDeliverer#validatePreferenceValues(java.util.HashMap)
 */
public void validatePreferenceValues(HashMap<String, String> prefs) throws ErrorList {
    boolean error = false;
    ErrorList errorList = new ErrorList();
    String[] validformats = {"text","html"};

    if (!prefs.containsKey(getName()+"."+EMAIL_ADDR_PREF_KEY)) {
        errorList.addError("Email Address is a required field.");
        error = true;
    } else {
        String addressValue = (String) prefs.get(getName()+"."+EMAIL_ADDR_PREF_KEY);
        EmailValidator validator = EmailValidator.getInstance();
        if (!validator.isValid(addressValue)) {
            errorList.addError("Email Address is required and must be properly formatted - \"[email protected]\".");
            error = true;
        }
    }

    // validate format
    if (!prefs.containsKey(getName()+"."+EMAIL_DELIV_FRMT_PREF_KEY)) {
        errorList.addError("Email Delivery Format is required.");
        error = true;
    } else {
        String formatValue = (String) prefs.get(getName()+"."+EMAIL_DELIV_FRMT_PREF_KEY);
        Set<String> formats = new HashSet<String>();
        for (int i=0; i < validformats.length ; i++) {
            formats.add(validformats[i]);
        }

        if (!formats.contains(formatValue)) {
            errorList.addError("Email Delivery Format is required and must be entered as \"text\" or \"html\".");
            error = true;
        }
    }

    if (error) throw errorList;
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:40,代码来源:EmailMessageDeliverer.java

示例5: saveRecipientPreferences

import org.kuali.rice.kcb.exception.ErrorList; //导入依赖的package包/类
@Test
public void saveRecipientPreferences() throws ErrorList {
    RecipientPreferenceService impl = services.getRecipientPreferenceService();
    MessageDelivererRegistryService delivererService = services.getMessageDelivererRegistryService();
    MessageDeliverer deliverer = delivererService.getDelivererByName(VALID_DELIVERER_NAME);
    if (deliverer == null) {
        throw new RuntimeException("Message deliverer could not be obtained");
    }
        
    HashMap<String, String> userprefs = new HashMap<String, String>();
    userprefs.put(VALID_PROPERTY, VALID_VALUE);
    userprefs.put("Email.email_delivery_format", "text");

    impl.saveRecipientPreferences(VALID_USER_ID, userprefs, deliverer);

    QueryByCriteria.Builder criteria = QueryByCriteria.Builder.create();
    criteria.setPredicates(equal("recipientId", VALID_USER_ID));
    List<RecipientPreference> prefs =
            KRADServiceLocator.getDataObjectService().findMatching(RecipientPreference.class, criteria.build()).getResults();
    assertEquals(2, prefs.size());
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:22,代码来源:RecipientPreferenceServiceTest.java

示例6: saveRecipientPreferences

import org.kuali.rice.kcb.exception.ErrorList; //导入依赖的package包/类
/**
 * @see org.kuali.rice.kcb.service.RecipientPreferenceService#saveRecipientPreferences(java.lang.String, java.util.HashMap, org.kuali.rice.kcb.deliverer.MessageDeliverer)
 */
public void saveRecipientPreferences(String recipientId, HashMap<String, String> prefs, MessageDeliverer deliverer) throws ErrorList {
    deliverer.validatePreferenceValues(prefs);         
    
    for (Map.Entry<String, String> entry: prefs.entrySet()) {
       String prop = entry.getKey();
       String value = entry.getValue();
           
       // We need to check if this property is already set
       // for the user by checking doing a unique key query...if
       // it already exists, update, otherwise add it 
       RecipientPreference currentPreference = getRecipientPreference(recipientId, prop);
       if (currentPreference != null) {
          currentPreference.setRecipientId(recipientId);
          currentPreference.setProperty(prop);
          currentPreference.setValue(value);
          dao.save(currentPreference);
       } else {
          RecipientPreference recipientPreference = new RecipientPreference();
          recipientPreference.setRecipientId(recipientId);
          recipientPreference.setProperty(prop);
          recipientPreference.setValue(value);
          dao.save(recipientPreference);
       }
    }
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:29,代码来源:RecipientPreferenceServiceImpl.java

示例7: saveRecipientPreferences

import org.kuali.rice.kcb.exception.ErrorList; //导入依赖的package包/类
@Test
public void saveRecipientPreferences() throws ErrorList {
    RecipientPreferenceService impl = services.getRecipientPreferenceService();
    MessageDelivererRegistryService delivererService = services.getMessageDelivererRegistryService();
    MessageDeliverer deliverer = delivererService.getDelivererByName(VALID_DELIVERER_NAME);
    if (deliverer == null) {
        throw new RuntimeException("Message deliverer could not be obtained");
    }
        
    HashMap<String, String> userprefs = new HashMap<String, String>();
    userprefs.put(VALID_PROPERTY, VALID_VALUE);
    userprefs.put("Email.email_delivery_format", "text");

    impl.saveRecipientPreferences(VALID_USER_ID, userprefs, deliverer);
    
    RecipientPreference recipientPreference = new RecipientPreference();
    recipientPreference.setRecipientId(VALID_USER_ID);
    Collection<RecipientPreference> prefs = services.getKcbGenericDao().findMatchingByExample(recipientPreference);
    assertEquals(2, prefs.size());
}
 
开发者ID:aapotts,项目名称:kuali_rice,代码行数:21,代码来源:RecipientPreferenceServiceTest.java

示例8: validatePreferenceValues

import org.kuali.rice.kcb.exception.ErrorList; //导入依赖的package包/类
/**
 * @see org.kuali.rice.kcb.deliverer.MessageDeliverer#validatePreferenceValues(java.util.HashMap)
 */
public void validatePreferenceValues(HashMap prefs) throws ErrorList {
    // no validation for now
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:7,代码来源:MockMessageDeliverer.java

示例9: saveRecipientPreferences

import org.kuali.rice.kcb.exception.ErrorList; //导入依赖的package包/类
/**
 * This method will save a user recipient preferences in the system.
 * @param userid
 * @param prefs a hashmap of key/values
 * @param deliveryTypeName name of deliverer
 */
public void saveRecipientPreferences(String userid, HashMap<String, String> prefs, MessageDeliverer deliverer) throws ErrorList;
 
开发者ID:kuali,项目名称:kc-rice,代码行数:8,代码来源:RecipientPreferenceService.java

示例10: validatePreferenceValues

import org.kuali.rice.kcb.exception.ErrorList; //导入依赖的package包/类
/**
 * This method is responsible for validating preference values when a person saves their preferences for the particular
 * NotificationMessageDeliverer.  For example, if "phoneNumber" is one of the preferences for an SMS deliverer, 
 * then this method would be responsible for validating the value entered by a particular user such that it was properly 
 * constructed with hyphens or not, etc.  Errors would be constructed and added to the ErrorList instance and be thrown from 
 * the method if any occurred.
 * @throws ErrorList
 */
public void validatePreferenceValues(HashMap<String, String> prefs) throws ErrorList;
 
开发者ID:kuali,项目名称:kc-rice,代码行数:10,代码来源:MessageDeliverer.java


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