Пример #1
0
 public void validate() {
   CheckConditions.checkCondition(
       !RESERVED_FIELD_NAME.contains(getName()),
       new IllegalMetaClassException(String.format("Reserved meta field name %s!", getName())));
   CheckConditions.checkCondition(
       !StringUtils.isNullOrEmpty(getName()),
       new IllegalMetaClassException("meta field name can not be empty"));
   CheckConditions.checkCondition(
       !StringUtils.isNullOrEmpty(getName().trim()),
       new IllegalMetaClassException("meta field name can not be empty"));
   CheckConditions.checkCondition(
       org.apache.commons.lang.StringUtils.containsNone(
           getName(), CMSConsts.INVALID_META_FIELD_NAME_CHARACTERS),
       new IllegalMetaClassException(
           "meta field "
               + name
               + " cannot contains invalid characters: "
               + Arrays.toString(CMSConsts.INVALID_META_FIELD_NAME_CHARACTERS)));
   if (!isInternal()) {
     CheckConditions.checkCondition(
         !INVALID_PATTERN.matcher(getName()).matches(),
         new IllegalMetaClassException(
             "meta field name can not start with regex _[A-Za-z0-9]: " + getName()));
   }
 }
Пример #2
0
 /**
  * Removes all control characters from passed in String.
  *
  * @param pkgId package id
  * @param input char input
  */
 protected static String sanitize(Long pkgId, String input) {
   if (StringUtils.containsNone(input, CONTROL_CHARS)) {
     return input;
   }
   if (log.isDebugEnabled()) {
     log.debug(
         "Package " + pkgId + " metadata contains control chars, cleanup required: " + input);
   }
   return StringUtils.replaceChars(input, CONTROL_CHARS, CONTROL_CHARS_REPLACEMENT);
 }