private Set<String> validateURL(ValidationHelper helper, Context context, String url) {
        String pathToCheck = url;
        Set<String> serverVariables = new HashSet<String>();

        while (pathToCheck.contains("{")) {
            if (!pathToCheck.contains("}")) {
                final String message = Tr.formatMessage(tc, "serverInvalidURL", pathToCheck);
                helper.addValidationEvent(new ValidationEvent(ValidationEvent.Severity.ERROR, context.getLocation("url"), message));
                return serverVariables;
            }
            int firstIndex = pathToCheck.indexOf("{");
            int lastIndex = pathToCheck.indexOf("}");

            if (firstIndex > lastIndex) {
                final String message = Tr.formatMessage(tc, "serverInvalidURL", pathToCheck);
                helper.addValidationEvent(new ValidationEvent(ValidationEvent.Severity.ERROR, context.getLocation("url"), message));
                return serverVariables;
            }

            String variable = pathToCheck.substring(firstIndex + 1, lastIndex);

            if (variable.isEmpty() || variable.contains("{") || variable.contains("/")) {
                final String message = Tr.formatMessage(tc, "serverInvalidURL", pathToCheck);
                helper.addValidationEvent(new ValidationEvent(ValidationEvent.Severity.ERROR, context.getLocation("url"), message));
                return serverVariables;
            }

            serverVariables.add(variable);
            pathToCheck = pathToCheck.substring(lastIndex + 1);
        }

        if (pathToCheck.contains("}")) {
            final String message = Tr.formatMessage(tc, "serverInvalidURL", pathToCheck);
            helper.addValidationEvent(new ValidationEvent(ValidationEvent.Severity.ERROR, context.getLocation("url"), message));
            return serverVariables;
        }

        return serverVariables;
    }
private Set < String > validateURL ( ValidationHelper helper , Context context , String url ) { String pathToCheck = url ; Set < String > serverVariables = new HashSet < String > ( ) ; while ( pathToCheck . contains ( "{" ) ) { if ( ! pathToCheck . contains ( "}" ) ) { final String message = Tr . formatMessage ( tc , "serverInvalidURL" , pathToCheck ) ; helper . addValidationEvent ( new ValidationEvent ( ValidationEvent . Severity . ERROR , context . getLocation ( "url" ) , message ) ) ; return serverVariables ; } int firstIndex = pathToCheck . indexOf ( "{" ) ; int lastIndex = pathToCheck . indexOf ( "}" ) ; if ( firstIndex > lastIndex ) { final String message = Tr . formatMessage ( tc , "serverInvalidURL" , pathToCheck ) ; helper . addValidationEvent ( new ValidationEvent ( ValidationEvent . Severity . ERROR , context . getLocation ( "url" ) , message ) ) ; return serverVariables ; } String variable = pathToCheck . substring ( firstIndex + 1 , lastIndex ) ; if ( variable . isEmpty ( ) || variable . contains ( "{" ) || variable . contains ( "/" ) ) { final String message = Tr . formatMessage ( tc , "serverInvalidURL" , pathToCheck ) ; helper . addValidationEvent ( new ValidationEvent ( ValidationEvent . Severity . ERROR , context . getLocation ( "url" ) , message ) ) ; return serverVariables ; } serverVariables . add ( variable ) ; pathToCheck = pathToCheck . substring ( lastIndex + 1 ) ; } if ( pathToCheck . contains ( "}" ) ) { final String message = Tr . formatMessage ( tc , "serverInvalidURL" , pathToCheck ) ; helper . addValidationEvent ( new ValidationEvent ( ValidationEvent . Severity . ERROR , context . getLocation ( "url" ) , message ) ) ; return serverVariables ; } return serverVariables ; }
Validate the url and extract server variables parameters