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;
}
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();
}
}
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();
}
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();
}
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();
}
}
}
Aggregations