use of jp.ossc.nimbus.io.RecurciveSearchFile in project nimbus by nimbus-org.
the class SFTPClientImpl method mput.
public void mput(String local, String remoteDir, String mode) throws SFTPException {
if (channel == null) {
throw new SFTPException("Connection is not established!");
}
if (remoteDir == null) {
remoteDir = "./";
} else if (!remoteDir.endsWith("/")) {
remoteDir += "/";
}
RecurciveSearchFile rsf = new RecurciveSearchFile(lpwd().getPath());
File[] localFiles = rsf.listAllTreeFiles(local);
for (int i = 0; i < localFiles.length; i++) {
if (mode == null) {
put(localFiles[i].getAbsolutePath(), remoteDir + localFiles[i].getName());
} else {
put(localFiles[i].getAbsolutePath(), remoteDir + localFiles[i].getName(), mode);
}
}
}
use of jp.ossc.nimbus.io.RecurciveSearchFile in project nimbus by nimbus-org.
the class SCPClientImpl method mput.
public void mput(String local, String remoteDir, String mode) throws SCPException {
if (connection == null) {
throw new SCPException("Connection is not established!");
}
if (scpClient == null) {
throw new SCPException("It is not authenticated!");
}
RecurciveSearchFile rsf = new RecurciveSearchFile(".");
File[] localFiles = rsf.listAllTreeFiles(local);
try {
for (int i = 0; i < localFiles.length; i++) {
if (mode == null) {
scpClient.put(localFiles[i].getPath(), remoteDir);
} else {
scpClient.put(localFiles[i].getPath(), remoteDir, mode);
}
}
} catch (IOException e) {
throw new SCPException("It failed to mput! local=" + local, e);
}
}
use of jp.ossc.nimbus.io.RecurciveSearchFile in project nimbus by nimbus-org.
the class CashedClassLoader method setupDirPropList.
//
/**
* Method ディレクトリ指定でクラス名を抽出する.
* @param item
*/
protected void setupDirPropList(URL item) {
String dirPath = StringOperator.replaceString(item.getFile(), C_BK_SRASH, C_SRASH);
if (!item.getFile().endsWith(C_SRASH)) {
dirPath = dirPath + C_SRASH;
}
RecurciveSearchFile file = new RecurciveSearchFile(dirPath);
ExtentionFileFilter filter = new ExtentionFileFilter(C_CLASS_EXT, true);
File[] list = file.listAllTreeFiles(filter);
for (int cnt = 0; cnt < list.length; cnt++) {
String path = list[cnt].getAbsolutePath();
// int pos = item.getFile().length();
// 2003.11.13 Hirokado -1追加
int pos = item.getFile().length() - 1;
path = path.substring(pos, path.length() - C_CLASS_EXT.length());
path = StringOperator.replaceString(path, C_SRASH, C_DOT);
Class cls = null;
try {
cls = this.loadClass(path);
} catch (ClassNotFoundException e) {
// $NON-NLS-1$//$NON-NLS-2$
throw new ServiceException("CASHCLASSLODER003", "ClassNotFoundException clsename = " + path, e);
}
mClassHash.put(path, cls);
}
}
use of jp.ossc.nimbus.io.RecurciveSearchFile in project nimbus by nimbus-org.
the class ResourceBundlePropertiesFactoryService method setupDirPropList.
//
/**
* Method ディレクトリ指定でプロパティファイルを抽出する.
* @param item
*/
protected void setupDirPropList(String item) {
String dirPath = StringOperator.replaceString(item, C_BK_SRASH, C_SRASH);
if (!item.endsWith(C_SRASH)) {
dirPath = dirPath + C_SRASH;
}
File dirPathFile = new File(dirPath);
int pos = dirPathFile.getAbsolutePath().length();
RecurciveSearchFile file = new RecurciveSearchFile(dirPath);
ExtentionFileFilter filter = new ExtentionFileFilter(C_PROP_EXT, true);
File[] list = file.listAllTreeFiles(filter);
for (int cnt = 0; cnt < list.length; cnt++) {
FileInputStream stream;
try {
stream = new FileInputStream(list[cnt]);
} catch (FileNotFoundException e) {
// $NON-NLS-1$ //$NON-NLS-2$
throw new ServiceException("PROPFACTORY002", "FileNotFoundException name = " + list[cnt], e);
}
ArrayProperties prop = new ArrayProperties(mEncode);
try {
prop.load(stream);
} catch (IOException e) {
// $NON-NLS-1$ //$NON-NLS-2$
throw new ServiceException("PROPFACTORY003", "IOException filename = " + list[cnt], e);
}
try {
stream.close();
} catch (IOException e) {
// $NON-NLS-1$ //$NON-NLS-2$
throw new ServiceException("PROPFACTORY004", "IOException filename = " + list[cnt], e);
}
String path = list[cnt].getAbsolutePath();
path = path.substring(pos + 1, path.length() - C_PROP_EXT.length());
path = StringOperator.replaceString(path, C_BK_SRASH, C_DOT);
path = StringOperator.replaceString(path, C_SRASH, C_DOT);
mPropHash.put(path, prop);
}
}
use of jp.ossc.nimbus.io.RecurciveSearchFile in project nimbus by nimbus-org.
the class TestControllerService method startScenario.
public synchronized void startScenario(String userId, String scenarioId) throws Exception {
getLogger().write("TC___00009", new Object[] { currentTestScenarioGroup.getScenarioGroupId(), scenarioId, userId });
try {
setUserId(userId);
if (currentTestScenarioGroup == null) {
throw new TestException("ScenarioGroup is not start.");
}
if (currentTestScenario != null) {
throw new TestException("Scenario is already started. ScenarioGroupId=" + currentTestScenario.getScenarioGroupId() + " ScenarioId=" + currentTestScenario.getScenarioId() + " UserId=" + currentTestScenario.getStatus().getUserId());
}
String[] scenarioIds = testResourceManager.getScenarioIds(currentTestScenarioGroup.getScenarioGroupId());
if (!Arrays.asList(scenarioIds).contains(scenarioId)) {
throw new TestException("This ScenarioId does not exist. ScenarioGroupId=" + currentTestScenarioGroup.getScenarioGroupId() + " ScenarioId=" + scenarioId);
}
TestScenarioGroupContext groupContext = (TestScenarioGroupContext) contextMap.get(currentTestScenarioGroup.getScenarioGroupId());
TestScenarioContext context = groupContext.getTestScenarioContext(scenarioId);
if (context != null) {
((TestScenarioImpl) context.getTestScenario()).clearResource();
TestScenario.Status scenarioStatus = context.getStatus();
if (scenarioStatus.getState() == TestScenario.Status.STARTED) {
if (scenarioStatus.getUserId() != null && !scenarioStatus.getUserId().equals(userId)) {
throw new TestException("TestScenario is Stated by another user. testScenarioId=" + scenarioId + " userId=" + scenarioStatus.getUserId());
}
cancelScenario(scenarioId);
}
}
context = new TestScenarioContext();
RecurciveSearchFile resourceDir = new RecurciveSearchFile(testResourceFileBaseDirectory, currentTestScenarioGroup.getScenarioGroupId() + File.separator + scenarioId);
downloadTestScenarioResource(resourceDir, currentTestScenarioGroup.getScenarioGroupId(), scenarioId);
if (testStubs != null) {
for (int i = 0; i < testStubs.length; i++) {
String stubId = testStubs[i].getId();
File tempDir = null;
try {
tempDir = new File(internalTestResourceFileTempDirectory, new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()));
if (!tempDir.mkdirs()) {
throw new IOException("Directory can not make. path=" + tempDir);
}
File[] caseDirs = resourceDir.listFiles();
if (caseDirs != null && caseDirs.length > 0) {
for (int j = 0; j < caseDirs.length; j++) {
RecurciveSearchFile caseDir = new RecurciveSearchFile(caseDirs[j]);
File[] files = caseDir.listAllTreeFiles("**/" + stubId, RecurciveSearchFile.SEARCH_TYPE_DIR);
if (files != null && files.length > 0) {
for (int k = 0; k < files.length; k++) {
File testcaseDir = new File(tempDir, files[k].getParentFile().getName());
if (!testcaseDir.exists()) {
if (!testcaseDir.mkdirs()) {
throw new IOException("Directory can not make. path=" + testcaseDir);
}
}
if (!RecurciveSearchFile.copyAllTree(files[k], testcaseDir)) {
throw new IOException("Directory can not copy. From=" + files[k] + " To=" + testcaseDir);
}
}
}
}
}
stubResourceManager.uploadScenarioResource(tempDir, currentTestScenarioGroup.getScenarioGroupId(), scenarioId, stubId);
testStubs[i].startScenario(userId, currentTestScenarioGroup.getScenarioGroupId(), scenarioId);
} finally {
if (tempDir != null && tempDir.exists()) {
if (!RecurciveSearchFile.deleteAllTree(tempDir)) {
RecurciveSearchFile.deleteOnExitAllTree(tempDir);
}
}
}
}
}
if (testEventListeners != null) {
for (int i = 0; i < testEventListeners.length; i++) {
testEventListeners[i].startScenario(userId, scenarioId);
}
}
TestScenarioImpl testScenario = new TestScenarioImpl(currentTestScenarioGroup.getScenarioGroupId(), scenarioId);
testScenario.setController(this);
context.setTestScenario(testScenario);
groupContext.putTestScenarioContext(context);
TestScenarioImpl.StatusImpl status = new TestScenarioImpl.StatusImpl(userId);
context.setStatus(status);
TestContextImpl scenarioTestContext = new TestContextImpl();
scenarioTestContext.setCurrentDirectory(resourceDir);
context.setScenarioTestContext(scenarioTestContext);
TestContextImpl testCaseTestContext = new TestContextImpl();
context.setTestCaseTestContext(testCaseTestContext);
scenarioTestContext.setTestScenario(testScenario);
TestScenarioResource testScenarioResource = testScenario.getTestScenarioResource();
if (testPhase == null || testScenarioResource.isExecutable(testPhase)) {
String[] beforeActionIds = testScenario.getTestScenarioResource().getBeforeActionIds();
try {
executeAction(context, scenarioTestContext, status, beforeActionIds, true, true, true);
} catch (NotSupportActionException e) {
throw new TestException("This action is not support at BeforeAction of Scenario. action=" + e.getAction().getClass().getName());
}
boolean result = context.isAllActionSuccess();
status.setResult(result);
status.setStartTime(new Date());
if (result) {
status.setState(TestScenario.Status.STARTED);
} else {
status.setState(TestScenario.Status.ERROR);
}
}
currentTestScenario = testScenario;
} catch (Exception e) {
if (testStubs != null) {
for (int i = 0; i < testStubs.length; i++) {
testStubs[i].cancelScenario();
}
}
currentTestScenario = null;
currentTestCase = null;
getLogger().write("TC___00010", new Object[] { currentTestScenarioGroup.getScenarioGroupId(), scenarioId }, e);
throw e;
}
}
Aggregations