use of org.apache.commons.vfs2.impl.StandardFileSystemManager in project wso2-synapse by wso2.
the class VFSTransportListener method doInit.
@Override
protected void doInit() throws AxisFault {
super.doInit();
try {
StandardFileSystemManager fsm = new StandardFileSystemManager();
fsm.setConfiguration(getClass().getClassLoader().getResource("providers.xml"));
fsm.init();
this.workerPool = super.workerPool;
fsManager = fsm;
Parameter lockFlagParam = getTransportInDescription().getParameter(VFSConstants.TRANSPORT_FILE_LOCKING);
if (lockFlagParam != null) {
String strLockingFlag = lockFlagParam.getValue().toString();
// by-default enabled, if explicitly specified as "disable" make it disable
if (VFSConstants.TRANSPORT_FILE_LOCKING_DISABLED.equals(strLockingFlag)) {
globalFileLockingFlag = false;
}
}
} catch (FileSystemException e) {
handleException("Error initializing the file transport : " + e.getMessage(), e);
}
}
use of org.apache.commons.vfs2.impl.StandardFileSystemManager in project wso2-synapse by wso2.
the class VFSTransportSender method init.
/**
* Initialize the VFS file system manager and be ready to send messages
* @param cfgCtx the axis2 configuration context
* @param transportOut the transport-out description
* @throws AxisFault on error
*/
public void init(ConfigurationContext cfgCtx, TransportOutDescription transportOut) throws AxisFault {
super.init(cfgCtx, transportOut);
try {
StandardFileSystemManager fsm = new StandardFileSystemManager();
fsm.setConfiguration(getClass().getClassLoader().getResource("providers.xml"));
fsm.init();
fsManager = fsm;
Parameter lckFlagParam = transportOut.getParameter(VFSConstants.TRANSPORT_FILE_LOCKING);
if (lckFlagParam != null) {
String strLockingFlag = lckFlagParam.getValue().toString();
// by-default enabled, if explicitly specified as "disable" make it disable
if (VFSConstants.TRANSPORT_FILE_LOCKING_DISABLED.equals(strLockingFlag)) {
globalFileLockingFlag = false;
}
}
Parameter strAutoLock = transportOut.getParameter(VFSConstants.TRANSPORT_AUTO_LOCK_RELEASE);
boolean autoLockRelease = false;
boolean autoLockReleaseSameNode = true;
Long autoLockReleaseInterval = null;
if (strAutoLock != null && strAutoLock.getValue() != null && !strAutoLock.getValue().toString().isEmpty()) {
try {
autoLockRelease = Boolean.parseBoolean(strAutoLock.getValue().toString());
} catch (Exception e) {
autoLockRelease = false;
log.warn("VFS Auto lock removal not set properly. Given value is : " + strAutoLock + ", defaults to - " + autoLockRelease, e);
}
if (autoLockRelease) {
Parameter strAutoLockInterval = transportOut.getParameter(VFSConstants.TRANSPORT_AUTO_LOCK_RELEASE_INTERVAL);
if (strAutoLockInterval != null && strAutoLockInterval.getValue() != null && !strAutoLockInterval.getValue().toString().isEmpty()) {
try {
autoLockReleaseInterval = Long.parseLong(strAutoLockInterval.getValue().toString());
} catch (Exception e) {
autoLockReleaseInterval = null;
log.warn("VFS Auto lock release interval is not set properly. Given value is : " + strAutoLockInterval + ", defaults to - null", e);
}
}
Parameter strAutoLockReleaseSameNode = transportOut.getParameter(VFSConstants.TRANSPORT_AUTO_LOCK_RELEASE_SAME_NODE);
if (strAutoLockReleaseSameNode != null && strAutoLockReleaseSameNode.getValue() != null && !strAutoLockReleaseSameNode.getValue().toString().isEmpty()) {
try {
autoLockReleaseSameNode = Boolean.parseBoolean(strAutoLockReleaseSameNode.getValue().toString());
} catch (Exception e) {
autoLockReleaseSameNode = true;
log.warn("VFS Auto lock removal same node property not set properly. Given value is : " + autoLockReleaseSameNode + ", defaults to - " + autoLockReleaseSameNode, e);
}
}
}
}
vfsParamDTO = new VFSParamDTO();
vfsParamDTO.setAutoLockRelease(autoLockRelease);
vfsParamDTO.setAutoLockReleaseInterval(autoLockReleaseInterval);
vfsParamDTO.setAutoLockReleaseSameNode(autoLockReleaseSameNode);
} catch (FileSystemException e) {
handleException("Error initializing the file transport : " + e.getMessage(), e);
}
}
use of org.apache.commons.vfs2.impl.StandardFileSystemManager in project Orthanc_Tools by salimkanoun.
the class ExportFiles method export.
public void export() {
FileInputStream fis = null;
try {
File localFile = new File(this.filePath);
switch(chosenOption) {
case OPTION_FTP:
FTPClient client = new FTPClient();
client.connect(this.serverAdress, this.port);
client.login(this.login, this.pwd);
client.enterLocalPassiveMode();
client.setFileType(FTPClient.BINARY_FILE_TYPE);
String remoteFile = this.remotePath + this.remoteFileName;
fis = new FileInputStream(localFile);
client.storeFile(remoteFile, fis);
client.logout();
break;
case OPTION_SFTP:
StandardFileSystemManager manager = new StandardFileSystemManager();
manager.init();
FileObject localFileSFTP = manager.resolveFile(this.filePath);
FileObject remoteFileSFTP = manager.resolveFile("sftp://" + this.login + ":" + this.pwd + "@" + this.serverAdress + ":" + this.port + this.remotePath + this.remoteFileName);
// Copy local file to sftp server
remoteFileSFTP.copyFrom(localFileSFTP, Selectors.SELECT_SELF);
manager.close();
break;
case OPTION_WEBDAV:
fis = new FileInputStream(localFile);
Sardine sardine = SardineFactory.begin(this.login, this.pwd);
sardine.put(this.serverAdress + this.remotePath + this.remoteFileName, fis);
break;
default:
break;
}
} catch (IOException e) {
// Getting the exception message, that we will give to VueAnon with getResult
this.result = e.getMessage();
} finally {
try {
fis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
use of org.apache.commons.vfs2.impl.StandardFileSystemManager in project jackrabbit by apache.
the class VFSDataStore method createFileSystemManager.
/**
* Creates a {@link FileSystemManager} instance.
* @return a {@link FileSystemManager} instance.
* @throws RepositoryException if an error occurs creating the manager.
*/
protected FileSystemManager createFileSystemManager() throws RepositoryException {
FileSystemManager fileSystemManager = null;
try {
if (getFileSystemManagerClassName() == null) {
fileSystemManager = new StandardFileSystemManager();
} else {
final Class<?> mgrClass = Class.forName(getFileSystemManagerClassName());
fileSystemManager = (FileSystemManager) mgrClass.newInstance();
}
if (fileSystemManager instanceof DefaultFileSystemManager) {
((DefaultFileSystemManager) fileSystemManager).init();
}
} catch (final FileSystemException e) {
throw new RepositoryException("Could not initialize file system manager of class: " + getFileSystemManagerClassName(), e);
} catch (final Exception e) {
throw new RepositoryException("Could not create file system manager of class: " + getFileSystemManagerClassName(), e);
}
return fileSystemManager;
}
use of org.apache.commons.vfs2.impl.StandardFileSystemManager in project jackrabbit by apache.
the class VFSFileSystem method createFileSystemManager.
/**
* Creates a {@link FileSystemManager} instance.
* @return a {@link FileSystemManager} instance.
* @throws FileSystemException if an error occurs creating the manager.
*/
protected FileSystemManager createFileSystemManager() throws FileSystemException {
FileSystemManager fileSystemManager = null;
try {
if (getFileSystemManagerClassName() == null) {
fileSystemManager = new StandardFileSystemManager();
} else {
final Class<?> mgrClass = Class.forName(getFileSystemManagerClassName());
fileSystemManager = (FileSystemManager) mgrClass.newInstance();
}
if (fileSystemManager instanceof DefaultFileSystemManager) {
((DefaultFileSystemManager) fileSystemManager).init();
}
} catch (final Exception e) {
throw new FileSystemException("Could not create file system manager of class: " + getFileSystemManagerClassName(), e);
}
return fileSystemManager;
}
Aggregations