src/main/java/application/rest/v1/actions/VariableResolver.java
// parameter 'suffix' is either variable-name or variable-name, default.string-constant 
parameter 'suffix' is either variable-name or variable-name, default.string-constant
parameter ' suffix ' is either variable - name or variable - name default . string - constant
@Override
    public String resolve(ResolutionContext context, String suffix) throws PatternException {
        String defaultValue= null; 
        int pos= suffix.indexOf(','); 
        if ( pos >= 0 ) { 
            defaultValue= suffix.substring(pos+1,suffix.length()); 
            defaultValue= defaultValue.substring(defaultValue.indexOf('.')+1,
                          defaultValue.length()); 
            suffix= suffix.substring(0,pos); 
        }
        if (Logger.isDebugEnabled()) {
            Logger.log(VariableResolver.class.getName(), "resolve", Logger.LogType.DEBUG, "For suffix="+suffix);
        }
        String value = context.getResolvedVariable(suffix);
        if (value != null) {
            if (Logger.isDebugEnabled()) {
                Logger.log(VariableResolver.class.getName(), "resolve", Logger.LogType.DEBUG, "Result=" + value);
            }
            return value;
        } 
        if (context.isVisitingVariable(suffix)) {
            if (Logger.isErrorEnabled()) {
                Logger.log(VariableResolver.class.getName(), "resolve", Logger.LogType.ERROR, "Suffix=" + suffix + " contains cycles in variable definitions.");
            }
            throw new PatternException(suffix + " contains cycles in variable definitions.");
        }
        final String varPattern = context.getVariablePattern(suffix);
        if (varPattern != null) {
            context.visitVariableStart(suffix); 
            try { 
                final ResolvedValue rv= context.resolve(varPattern);
                context.visitVariableEnd(); 
                if (rv.isFullyResolved()) {
                    value = rv.getValue();
                    context.setResolvedVariable(suffix, value);
                    if (Logger.isDebugEnabled()) {
                        Logger.log(VariableResolver.class.getName(), "resolve", Logger.LogType.DEBUG, "Result=" + value);
                    }
                    return value;
                }
            } 
            /* If can't resolve, check if there is a default value
               to return. If not, re-throw exception. */
            catch(PatternException e) { 
                if ( defaultValue == null ) { 
                    if (Logger.isErrorEnabled()) {
                        Logger.log(VariableResolver.class.getName(), "resolve", Logger.LogType.ERROR, suffix + "Default value is null and caught PatternException " + e.toString());
                    }
                    throw e; 
                } 
                else { 
                    if (Logger.isDebugEnabled()) {
                        Logger.log(VariableResolver.class.getName(), "resolve", Logger.LogType.DEBUG, "Return defaultValue=" + defaultValue);
                    }
                    return defaultValue; 
                }
            } 
        }
        /* If can't resolve, check if there is a default value
               to return. If not, throw exception. */        
        if ( defaultValue == null ) { 
            if (Logger.isErrorEnabled()) {
                Logger.log(VariableResolver.class.getName(), "resolve", Logger.LogType.ERROR, suffix + "Default value is null. Cannot resolve " + suffix);
            }
            throw new PatternException("can not resolve " + suffix);
        } 
        else { 
            if (Logger.isDebugEnabled()) {
                Logger.log(VariableResolver.class.getName(), "resolve", Logger.LogType.DEBUG, "Return defaultValue=" + defaultValue);
            }
            return defaultValue; 
        }
    }
@ Override public String resolve ( ResolutionContext context , String suffix ) throws PatternException { String defaultValue = null ; int pos = suffix . indexOf ( ',' ) ; if ( pos >= 0 ) { defaultValue = suffix . substring ( pos + 1 , suffix . length ( ) ) ; defaultValue = defaultValue . substring ( defaultValue . indexOf ( '.' ) + 1 , defaultValue . length ( ) ) ; suffix = suffix . substring ( 0 , pos ) ; } if ( Logger . isDebugEnabled ( ) ) { Logger . log ( VariableResolver . class . getName ( ) , "resolve" , Logger . LogType . DEBUG , "For suffix=" + suffix ) ; } String value = context . getResolvedVariable ( suffix ) ; if ( value != null ) { if ( Logger . isDebugEnabled ( ) ) { Logger . log ( VariableResolver . class . getName ( ) , "resolve" , Logger . LogType . DEBUG , "Result=" + value ) ; } return value ; } if ( context . isVisitingVariable ( suffix ) ) { if ( Logger . isErrorEnabled ( ) ) { Logger . log ( VariableResolver . class . getName ( ) , "resolve" , Logger . LogType . ERROR , "Suffix=" + suffix + " contains cycles in variable definitions." ) ; } throw new PatternException ( suffix + " contains cycles in variable definitions." ) ; } final String varPattern = context . getVariablePattern ( suffix ) ; if ( varPattern != null ) { context . visitVariableStart ( suffix ) ; try { final ResolvedValue rv = context . resolve ( varPattern ) ; context . visitVariableEnd ( ) ; if ( rv . isFullyResolved ( ) ) { value = rv . getValue ( ) ; context . setResolvedVariable ( suffix , value ) ; if ( Logger . isDebugEnabled ( ) ) { Logger . log ( VariableResolver . class . getName ( ) , "resolve" , Logger . LogType . DEBUG , "Result=" + value ) ; } return value ; } } /* If can't resolve, check if there is a default value
               to return. If not, re-throw exception. */ catch ( PatternException e ) { if ( defaultValue == null ) { if ( Logger . isErrorEnabled ( ) ) { Logger . log ( VariableResolver . class . getName ( ) , "resolve" , Logger . LogType . ERROR , suffix + "Default value is null and caught PatternException " + e . toString ( ) ) ; } throw e ; } else { if ( Logger . isDebugEnabled ( ) ) { Logger . log ( VariableResolver . class . getName ( ) , "resolve" , Logger . LogType . DEBUG , "Return defaultValue=" + defaultValue ) ; } return defaultValue ; } } } /* If can't resolve, check if there is a default value
               to return. If not, throw exception. */ if ( defaultValue == null ) { if ( Logger . isErrorEnabled ( ) ) { Logger . log ( VariableResolver . class . getName ( ) , "resolve" , Logger . LogType . ERROR , suffix + "Default value is null. Cannot resolve " + suffix ) ; } throw new PatternException ( "can not resolve " + suffix ) ; } else { if ( Logger . isDebugEnabled ( ) ) { Logger . log ( VariableResolver . class . getName ( ) , "resolve" , Logger . LogType . DEBUG , "Return defaultValue=" + defaultValue ) ; } return defaultValue ; } }
parameter 'suffix' is either variable-name or variable-name, default.string-constant
parameter ' suffix ' is either variable - name or variable - name default . string - constant
// Check if default.string-constant specified. If so, separate variable name from default value. // grab default value expression  // strip off 'default.' prefix // grab variable name  // Immediately return the value if the variable has been previously resolved. // Guard against cycles in variable definitions. // (e.g. var x = "${var.y}", var y = "${var.z}", var z = "${var.x}"). // Retrieve the pattern from the config map and resolve the variable. // Housekeeping for cycle check // Housekeeping for cycle check // Cache the resolved value.