@Override
    public List<Script> getScripts(String name) throws ScriptBuilderException {

        List<Script> scripts = new ArrayList<>();
        if (!name.endsWith(".*")) {
            String toSearch = name.replaceAll("\\.", File.separator) + Script.EXTENSION;
            for (File path : paths) {
                File f = new File(path.getPath() + File.separator + toSearch);
                if (f.exists()) {
                    scripts.add(builder.build(f));
                    break;
                }
            }

        } else {

            //We need to consolidate the errors in allEx and rethrow it at the end if necessary
            ScriptBuilderException allEx = null;
            String base = name.substring(0, name.length() - 2).replaceAll("\\.", File.separator);
            for (File path : paths) {
                File f = new File(path.getPath() + File.separator + base);
                File[] files = f.listFiles();
                if (f.isDirectory() && files != null) {
                    for (File sf : files) {
                        if (sf.getName().endsWith(Script.EXTENSION)) {

                            try {
                                scripts.add(builder.build(sf));
                            } catch (ScriptBuilderException ex) {
                                if (allEx == null) {
                                    allEx = ex;
                                } else {
                                    allEx.getErrorReporter().getErrors().addAll(ex.getErrorReporter().getErrors());
                                }
                            }
                        }
                    }
                }
            }
            if (allEx != null) {
                throw allEx;
            }
        }
        return scripts;
    }
@ Override public List < Script > getScripts ( String name ) throws ScriptBuilderException { List < Script > scripts = new ArrayList < > ( ) ; if ( ! name . endsWith ( ".*" ) ) { String toSearch = name . replaceAll ( "\\." , File . separator ) + Script . EXTENSION ; for ( File path : paths ) { File f = new File ( path . getPath ( ) + File . separator + toSearch ) ; if ( f . exists ( ) ) { scripts . add ( builder . build ( f ) ) ; break ; } } } else { ScriptBuilderException allEx = null ; String base = name . substring ( 0 , name . length ( ) - 2 ) . replaceAll ( "\\." , File . separator ) ; for ( File path : paths ) { File f = new File ( path . getPath ( ) + File . separator + base ) ; File [ ] files = f . listFiles ( ) ; if ( f . isDirectory ( ) && files != null ) { for ( File sf : files ) { if ( sf . getName ( ) . endsWith ( Script . EXTENSION ) ) { try { scripts . add ( builder . build ( sf ) ) ; } catch ( ScriptBuilderException ex ) { if ( allEx == null ) { allEx = ex ; } else { allEx . getErrorReporter ( ) . getErrors ( ) . addAll ( ex . getErrorReporter ( ) . getErrors ( ) ) ; } } } } } } if ( allEx != null ) { throw allEx ; } } return scripts ; }
Get the script associated to a given identifier by browsing the given paths.
The first script having a matching identifier is selected, whatever the parsing process result will be

@param name the identifier of the script
@return the script if found
@throws org.btrplace.btrpsl.ScriptBuilderException if the builder was not able to parse the looked script