use of org.apache.synapse.commons.vfs.VFSParamDTO in project wso2-synapse by wso2.
the class VFSTransportListener method acquireLock.
private boolean acquireLock(FileSystemManager fsManager, FileObject fileObject, final PollTableEntry entry, FileSystemOptions fso, boolean isListener) {
VFSParamDTO vfsParamDTO = new VFSParamDTO();
vfsParamDTO.setAutoLockRelease(entry.getAutoLockRelease());
vfsParamDTO.setAutoLockReleaseSameNode(entry.getAutoLockReleaseSameNode());
vfsParamDTO.setAutoLockReleaseInterval(entry.getAutoLockReleaseInterval());
return VFSUtils.acquireLock(fsManager, fileObject, vfsParamDTO, fso, isListener);
}
use of org.apache.synapse.commons.vfs.VFSParamDTO 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);
}
}
Aggregations