Search in sources :

Example 6 with RecurciveSearchFile

use of jp.ossc.nimbus.io.RecurciveSearchFile in project nimbus by nimbus-org.

the class TextEvaluateActionService method toFiles.

protected List toFiles(TestContext context, String path) throws IOException {
    List result = null;
    path = replaceProperty(path);
    if (path.equals(".")) {
        path = context.getCurrentDirectory().getPath();
    } else if (path.startsWith("./")) {
        path = context.getCurrentDirectory().getPath() + path.substring(1);
    }
    File file = new File(path);
    if (file.exists()) {
        result = new ArrayList();
        result.add(file);
    } else {
        File parentFile = file;
        while ((parentFile = parentFile.getParentFile()) != null && !parentFile.exists()) ;
        if (parentFile == null) {
            parentFile = context.getCurrentDirectory();
        } else {
            path = path.substring(parentFile.getPath().length() + 1);
        }
        try {
            RecurciveSearchFile rsf = new RecurciveSearchFile(parentFile);
            File[] files = rsf.listAllTreeFiles(path, RecurciveSearchFile.SEARCH_TYPE_FILE);
            if (files != null && files.length != 0) {
                result = new ArrayList();
                for (int i = 0; i < files.length; i++) {
                    result.add(files[i]);
                }
            }
        } catch (PatternSyntaxException e) {
        }
    }
    return result;
}
Also used : RecurciveSearchFile(jp.ossc.nimbus.io.RecurciveSearchFile) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) RecurciveSearchFile(jp.ossc.nimbus.io.RecurciveSearchFile) PatternSyntaxException(java.util.regex.PatternSyntaxException)

Example 7 with RecurciveSearchFile

use of jp.ossc.nimbus.io.RecurciveSearchFile in project nimbus by nimbus-org.

the class HttpTestStubService method endScenario.

public void endScenario() throws Exception {
    synchronized (lock) {
        if (scenarioGroupId == null && scenarioId == null) {
            return;
        }
        RecurciveSearchFile scenarioDir = new RecurciveSearchFile(new File(resourceDirectory, scenarioGroupId), scenarioId);
        responseMap.clear();
        binaryMap.clear();
        evidenceMap.clear();
        responseCacheMap.clear();
        userId = null;
        this.scenarioGroupId = null;
        this.scenarioId = null;
        this.testcaseId = null;
        scenarioDir.deleteAllTree();
    }
}
Also used : RecurciveSearchFile(jp.ossc.nimbus.io.RecurciveSearchFile) RecurciveSearchFile(jp.ossc.nimbus.io.RecurciveSearchFile) File(java.io.File)

Example 8 with RecurciveSearchFile

use of jp.ossc.nimbus.io.RecurciveSearchFile in project nimbus by nimbus-org.

the class LocalStubResourceManagerService method downloadResource.

private void downloadResource(File dir, String[] dirs) throws Exception {
    if (!dir.exists()) {
        dir.mkdirs();
    }
    RecurciveSearchFile subDir = new RecurciveSearchFile(internalTemporaryDirectory);
    for (int i = 0, imax = dirs.length; i < imax; i++) {
        subDir = new RecurciveSearchFile(subDir, dirs[i]);
    }
    if (!subDir.exists()) {
        throw new Exception("ScenarioResource not found." + subDir);
    }
    subDir.copyAllTree(dir);
    subDir.deleteAllTree();
}
Also used : RecurciveSearchFile(jp.ossc.nimbus.io.RecurciveSearchFile) IOException(java.io.IOException)

Example 9 with RecurciveSearchFile

use of jp.ossc.nimbus.io.RecurciveSearchFile in project nimbus by nimbus-org.

the class LocalStubResourceManagerService method uploadResource.

private void uploadResource(File dir, String[] dirs) throws Exception {
    if (!dir.exists()) {
        throw new Exception("UploadDirectory is not existed.");
    }
    RecurciveSearchFile subDir = new RecurciveSearchFile(internalTemporaryDirectory);
    for (int i = 0, imax = dirs.length; i < imax; i++) {
        subDir = new RecurciveSearchFile(subDir, dirs[i]);
        if (i == imax - 1 && subDir.exists()) {
            subDir.deleteAllTree();
        }
        if (subDir.mkdir()) {
            subDir.deleteOnExit();
        }
    }
    RecurciveSearchFile uploadDir = new RecurciveSearchFile(dir.getAbsolutePath());
    uploadDir.copyAllTree(subDir);
    subDir.deleteOnExitAllTree();
}
Also used : RecurciveSearchFile(jp.ossc.nimbus.io.RecurciveSearchFile) IOException(java.io.IOException)

Example 10 with RecurciveSearchFile

use of jp.ossc.nimbus.io.RecurciveSearchFile in project nimbus by nimbus-org.

the class LocalTestResourceManagerService method linkTemplate.

protected void linkTemplate(File dir, boolean isRecurcive) throws Exception {
    File[] linkFiles = null;
    if (isRecurcive) {
        RecurciveSearchFile targetDir = new RecurciveSearchFile(dir);
        linkFiles = targetDir.listAllTreeFiles(new ExtentionFileFilter(templateLinkFileExtention));
    } else {
        linkFiles = dir.listFiles(new ExtentionFileFilter(templateLinkFileExtention));
    }
    if (linkFiles != null) {
        Set deleteDataFiles = new HashSet();
        for (int i = 0; i < linkFiles.length; i++) {
            if (linkFiles[i].isDirectory()) {
                continue;
            }
            createTemplateFile(linkFiles[i], deleteDataFiles);
        }
        Iterator dataFiles = deleteDataFiles.iterator();
        while (dataFiles.hasNext()) {
            ((File) dataFiles.next()).delete();
        }
    }
}
Also used : RecurciveSearchFile(jp.ossc.nimbus.io.RecurciveSearchFile) Set(java.util.Set) HashSet(java.util.HashSet) Iterator(java.util.Iterator) File(java.io.File) RecurciveSearchFile(jp.ossc.nimbus.io.RecurciveSearchFile) ExtentionFileFilter(jp.ossc.nimbus.io.ExtentionFileFilter) HashSet(java.util.HashSet)

Aggregations

RecurciveSearchFile (jp.ossc.nimbus.io.RecurciveSearchFile)14 File (java.io.File)11 IOException (java.io.IOException)6 ExtentionFileFilter (jp.ossc.nimbus.io.ExtentionFileFilter)4 FileInputStream (java.io.FileInputStream)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 JarFile (java.util.jar.JarFile)2 PatternSyntaxException (java.util.regex.PatternSyntaxException)2 ServiceException (jp.ossc.nimbus.lang.ServiceException)2 BufferedReader (java.io.BufferedReader)1 FileNotFoundException (java.io.FileNotFoundException)1 InputStreamReader (java.io.InputStreamReader)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 Map (java.util.Map)1