How to make VFS reading file when I want in wso2 esb - wso2

I have wrote a proxy in wso2 esb where I used VFS for reading and writing files.Now when I put the file in the transport.vfs.FileURI parameter the VFS listener automatically read the file and continue processing. But I don't want this. I want with my command VFS start reading file and process.But I don't know how should do this. can anyone help me?

I don't think there is a straightforward configuration for that in VFS. But there is a workaround always. :) In this case, I can think of 2.
1) Have you file in a different place and move to transport.vfs.FileURI location whenever you want VFS to process it.
2) Set transport.vfs.FileNamePattern (eg.*\.xml) and rename the file name (or extention) to match to it whenever you want to process it.

Related

How to run a batch file in siebel escript and execute plsql package through a batch file by passing a variable and to get the output

My requirement is to execute a plsql package through siebel escript. For that, I am planning to write a batch file which can be invoked in the escript.
in the batch file, I want to execute the package. But stuck at passing the input to package and get the output from it. Please help me with the code.
Thanks.
The quickest answer might be using Clib Send Command Method. This can be used to run commands on the siebel server, on any OS. eg:
Clib.system("dir /p C:\Backup");
So you could try invoking your bat file
Clib.system("C:\custom.bat arg1 arg2");
You will have to handle the variables in the bat file (or .sh) file and invoke your PLSQL from there.
The flip side is that there is no way of getting any output from the command line back to Siebel.
https://docs.oracle.com/cd/E14004_01/books/eScript/C_Language_Reference101.html#wp1008859
You can get the output back into Siebel indirectly by having the command pipe it to a text file and having Siebel process that file.
The only way to do this is to call the batch with Clib.system and have it save the output into a file. You then need to have some BS/Workflow to read the file and delete it.
It will work reliably if you are careful with the file naming to avoid concurrency issues.

log4cplus - flush file before writing in it

My need is quite simple:
with log4cplus, I'd like to be able to write a log in a log file and to flush the log file everytime before I write in it. This way, while I run my application, I will only have one single line in my log file.
I've tryed the append=False property, but it only flush the log file at startup.
I could do it by hand in C++ but I don't want to write C++ code as the product is already in prod.
Any idea ?
Thanks,
Use the ImmediateFlush property to force the file appender to flush after each event.

File Close Notification

I wish to know when another application finishes editing a file.
I am aware of FindFirstChangeNotification, ReadDirectoryChangesW and the FileSystemWatcher class, however I think these are only able to detect file creation and changes. Which won't allow me to know whether the file still has content which will be written to it in future or not. One solution would be to wait to ensure that all data has been written, but I feel that there should be a better way.
I wish to know when the process writing to the file closes the handle it has, I think writing a File System Filter Driver may allow for this, can anyone confirm? Or provide another method I which I could use. Also I would prefer not to rely on something like .net but I wouldn't rule it out.
Thanks very much, in advance.
You can poll this by trying to open the file in exclusive mode.
On windows you can use OpenFile with OF_SHARE_EXCLUSIVE.

c++: code works on local file but needs to be changed to fetch and read from http server

I need to change the following piece of code, and instead of reading from local file it needs to read from file on http server.
Any ideas on how i could achieve this by changing this code.
fahd
Open the file in binary mode and seek to the end to determine file size
If you are reading a file on an http server you need to make an http request to the server. You may use a library like libcurl to achieve this.
Avoid using C-casts.

Intercept windows open file

I'm trying to make a small program that could intercept the open process of a file.
The purpose is when an user double-click on a file in a given folder, windows would inform to the software, then it process that petition and return windows the data of the file.
Maybe there would be another solution like monitoring Open messages and force Windows to wait while the program prepare the contents of the file.
One application of this concept, could be to manage desencryption of a file in a transparent way to the user.
In this context, the encrypted file would be on the disk and when the user open it ( with double-click on it or with some application such as notepad ), the background process would intercept that open event, desencrypt the file and give the contents of that file to the asking application.
It's a little bit strange concept, it could be like "Man In The Middle" network concept, but with files instead of network packets.
Thanks for reading.
The best way to do it to cover all cases of opening from any program would be via a file system filter driver. This may be too complex for your needs though.
You can use the trick that Process Explorer uses to replace itself with task manager. Basically create a key like this:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\taskmgr.exe
Where you replace 'taskmgr.exe' with the name of the process to intercept. Then add a string value called 'Debugger' that has the path to your executable. E.g:
Debugger -> "C:\windows\system32\notepad.exe"
Every a process is run that matches the image name your process will actually be called as a debugger for that process with the path to the actual process as an argument.
You could use code injection and API redirection. You'd start your target process and then inject a DLL which hooks the windows API functions that you want to intercept. You then get called when the target process thinks it's calling OpenFile() or whatever and you can do what you like before passing the call on to the real API.
Google for "IAT hooking".
Windows has an option to encrypt files on the disk (file->properties->advanced->encrypt) and this option is completely transparent to the applications.
Maybe to encrypt decrypt file portions of a disk you should consider softwares like criptainer?
There is this software as well http://www.truecrypt.org/downloads (free and open source) but I haven't tried it.
Developing a custom solution sounds very difficult.