@FFDCIgnore(URISyntaxException.class)
    private String processString(String value, ExtendedAttributeDefinition attrDef, EvaluationContext context, boolean ignoreWarnings) throws ConfigEvaluatorException {
        if (attrDef == null) {
            return context.resolveString(value, ignoreWarnings);
        }

        String strValue = attrDef.resolveVariables() ? context.resolveString(value, ignoreWarnings) : value;

        // Normalize the value if this is a file or directory location type
        if (attrDef.getType() == MetaTypeFactory.LOCATION_DIR_TYPE ||
            attrDef.getType() == MetaTypeFactory.LOCATION_FILE_TYPE) {
            strValue = PathUtils.normalize(strValue);
        } else if (attrDef.getType() == MetaTypeFactory.LOCATION_TYPE) {
            // If it's the generic location type, it may be a URL or a file path.
            // If we can distinguish that this is a URL, don't do normalization.
            try {
                new URI(strValue);
            } catch (URISyntaxException e) {
                // assume this is a file path and normalize
                strValue = PathUtils.normalize(strValue);
            }
        }

        boolean optionFound = false;
        // Convert option value to correct case.
        String[] optionValues = attrDef.getOptionValues();
        if (optionValues != null) {
            for (int i = 0; i < optionValues.length; i++) {
                if (strValue.equalsIgnoreCase(optionValues[i])) {
                    strValue = optionValues[i];
                    optionFound = true;
                    break;
                }
            }
            // only get the labels if it isn't found in the values.  Usually it will be a value.
            if (!optionFound) {
                String[] optionLabels = attrDef.getOptionLabels();
                for (int i = 0; i < optionValues.length; i++) {
                    if (strValue.equalsIgnoreCase(optionLabels[i])) {
                        strValue = optionValues[i];
                        optionFound = true;
                        break;
                    }
                }
            }
        }

        // If it is an option and it was found then skip the validate since it isn't needed.
        if (!optionFound) {
            // Special case for Boolean, since we want to validate "true" or "false" and anything is fail to validate (rather than being treated as false)
            if (attrDef.getType() == AttributeDefinition.BOOLEAN) {
                if (!!!("true".equalsIgnoreCase(strValue))
                    && !!!("false".equalsIgnoreCase(strValue))) {
                    Object[] inserts = new Object[] { strValue, attrDef.getID(), "false" }; // "false" is the default default
                    if (attrDef.getDefaultValue() != null && attrDef.getDefaultValue().length > 0)
                        inserts[2] = attrDef.getDefaultValue()[0];
                    throw new AttributeValidationException(attrDef, strValue, Tr.formatMessage(tc, "error.invalid.boolean.attribute", inserts));
                }
            } else if (attrDef.getType() != MetaTypeFactory.PID_TYPE) {
                // The validate method treats whitespace, commas, and
                // backslashes specially, but we've already done all that
                // processing and just want to validate a single value, so
                // escape all the special characters.  (It might be less effort
                // to just reimplement the validate method entirely.)
                String validateResult = attrDef.validate(MetaTypeHelper.escapeValue(strValue));
                if (validateResult != null && validateResult.length() > 0) {
                    throw new AttributeValidationException(attrDef, strValue, validateResult);
                }
            }
        }

        return strValue;
    }
@ FFDCIgnore ( URISyntaxException . class ) private String processString ( String value , ExtendedAttributeDefinition attrDef , EvaluationContext context , boolean ignoreWarnings ) throws ConfigEvaluatorException { if ( attrDef == null ) { return context . resolveString ( value , ignoreWarnings ) ; } String strValue = attrDef . resolveVariables ( ) ? context . resolveString ( value , ignoreWarnings ) : value ; if ( attrDef . getType ( ) == MetaTypeFactory . LOCATION_DIR_TYPE || attrDef . getType ( ) == MetaTypeFactory . LOCATION_FILE_TYPE ) { strValue = PathUtils . normalize ( strValue ) ; } else if ( attrDef . getType ( ) == MetaTypeFactory . LOCATION_TYPE ) { try { new URI ( strValue ) ; } catch ( URISyntaxException e ) { strValue = PathUtils . normalize ( strValue ) ; } } boolean optionFound = false ; String [ ] optionValues = attrDef . getOptionValues ( ) ; if ( optionValues != null ) { for ( int i = 0 ; i < optionValues . length ; i ++ ) { if ( strValue . equalsIgnoreCase ( optionValues [ i ] ) ) { strValue = optionValues [ i ] ; optionFound = true ; break ; } } if ( ! optionFound ) { String [ ] optionLabels = attrDef . getOptionLabels ( ) ; for ( int i = 0 ; i < optionValues . length ; i ++ ) { if ( strValue . equalsIgnoreCase ( optionLabels [ i ] ) ) { strValue = optionValues [ i ] ; optionFound = true ; break ; } } } } if ( ! optionFound ) { if ( attrDef . getType ( ) == AttributeDefinition . BOOLEAN ) { if ( ! ! ! ( "true" . equalsIgnoreCase ( strValue ) ) && ! ! ! ( "false" . equalsIgnoreCase ( strValue ) ) ) { Object [ ] inserts = new Object [ ] { strValue , attrDef . getID ( ) , "false" } ; if ( attrDef . getDefaultValue ( ) != null && attrDef . getDefaultValue ( ) . length > 0 ) inserts [ 2 ] = attrDef . getDefaultValue ( ) [ 0 ] ; throw new AttributeValidationException ( attrDef , strValue , Tr . formatMessage ( tc , "error.invalid.boolean.attribute" , inserts ) ) ; } } else if ( attrDef . getType ( ) != MetaTypeFactory . PID_TYPE ) { String validateResult = attrDef . validate ( MetaTypeHelper . escapeValue ( strValue ) ) ; if ( validateResult != null && validateResult . length ( ) > 0 ) { throw new AttributeValidationException ( attrDef , strValue , validateResult ) ; } } } return strValue ; }
@param attrDef the attribute definition, or null if this is a simple evaluation