I need to add/delete domain names to BIND 9.x DNS server. That means i need to read/write to zone files. How can I do this operation using Java?
It is possible to read zone files with sftp (JSch) but parsing, appending files is too complex.
Webmin uses perl scripts and perform these operations successfully.
DNSBoss uses Java and perform these operations successfully but it is not open source.
It seems dnsjava is helpful but I am not sure, I need to dig it more.
Do you have an idea for this operation? Any open source libraries, APIs which can be helpful?
Thanks a lot,
I realized there is a patch named Bind DZL. I should use it and forget about manipulating files.
Related
An application that I am currently working on contains several files of the above mentioned type. These files are created using NSArchiver from an legacy framework called OpenStep.
If I am correct than this is a data format which was used pre and begin OS/X and is now replaced by NSKeyedArchiver. Although I think current OS/X implementations of NSUnArchiver can still read this older format.
When opening these files there are some contents which can be read by humans like dataformats such as BlockArray, NSObject etc. The rest is binary data which does not make sense.
I have to be able to retrieve information from these files to process further in a Java based application. I would love to know what you would advise me to do in this case so that I am able to use the information in these files.
A side note:
The GNUSTEP implementation does not support this typedstream data.
My main application is written in Java.
Preferably a solution which does not require me to develop on the OS/X platform.
Solution should run on Windows platform.
I'm using Apache POI API to access an Excel .xlsx file, using the API I can read/write cells.
My problem is: How can I do that with the .xlsx file opened in Excel GUI?
If I try to do that I have conflict arising from concurrent access to the same resource (The process cannot access the file because it is being used by another process).
I have been told that the answer is Excel RTD and c#, c++ or other languages.
BUT I want to stick with Java,what could I do? Is switching to linux an option?
THANKS!!!
AFAIK poi only works on the file system, so there is no interaction through Real-Time Data. I think you should not edit the xlsx file while it is still open in excel if you want to prevent corruption.
If you want to use RTD, you should try to find java bindings for that. I think they are COM based, so maybe JACOB can help you. http://sourceforge.net/projects/jacob-project/
See also this discussion: http://sourceforge.net/p/jacob-project/discussion/375946/thread/946012e8/
Oh. Btw. COM is Windows only, so I would stay on Windows :)
Accessing and modifying a resources by 2 separate entities at the same time does not imply that you'll end up with a synchronized version at both ends. On the contrary, provided you manage to do so you have all the chances of ending up with an incorrect/bogus/corrupted result. Translated into java, you may think of it as multiple threads altering a variable in an unsynchronized way.
Some programs (notepad++, idea, eclipse on editor reactivation, etc) have implemented additional mechanisms which will detect if a file has been modified on the file-system outside the program itself, and provide you with options such as: reload file, ignore modifications, merge, etc, and others simply ignore these changes overwriting the file.
My guess is you'd have to do a similar thing or rethink your scenario about updating the files and triggering notifications.
As the other users said, there is no way to do this from poi. Options:
Your best option is RTD (you write a thin RTD "server" in C#, install it in the registry, and talk to it from java, e.g. via some socket; within excel, users just enter RTD formulas in their cells, for which excel calls your rtd server to get the latest data).
You can also write the data directly to excel using COM (there are also java libraries to do this, such as teamdev's jexcel, or you could write your own com wrappers).
You can write your own excel plugin.
Finally, there are lower level solutions which I've heard talk of but don't understand.
I have an embedded system using a python interface. Currently the system is using a (system-local) XML-file to persist data in case the system gets turned off. But normally the system is running the entire time. When the system starts, the XML-file is read in and information is stored in python-objects. The information then is used for processing. My aim is to edit this information remotely (over TCP/IP) even during process. I would like to use JAVA to get this done, and i have been thinking about something to share the objects. The problem is, that I'm missing some keywords to find the right technologies to get this done. What i found is SOAP, but i think it is not the right thing for this case, is that true? I'm grateful for any tips.
As I understand, you are using XML file to store start up configuration
And my assumptions on your interface between Java & Python apps
You want your Java application to retrieve objects over Python interface
And process them locally and send it back to Python interface to reload config ?
So, depending on your circumstances, you can workout something with the following
Jython
Pickle (if you have no restriction on startup config file format or can afford to do conversion)
https://pypi.python.org/pypi/Pyro4
Also you can get some ideas from here:
Sharing a complex object between Python processes?
You should ask your python application to open a XML-RPC socket which clients can connect on. This could let an outside application to execute an endpoint, which would manipulate your python object values in someway. There are several good choices for Java XML-RPC libraries, including the amazing org.apache.xmlrpc library.
I am implementing a workflow of tasks in a Java program.
One of the tasks is running some commands on multiple Linux servers.
The servers are determined dynamically - read from an XML file.
I examined Rundeck's API, but it seems that I have to configure the servers in advance, which doesn't suit my needs.
Any ideas?
One answer is to use rundeck, I think you just need rundeck to dynamically load your nodes.
To make it dynamic you need to refresh the project. Simply restart rundeck or use the api refresh method. I haven't tried the latter which I think is the better solution. The Resource Model supports files and getting your node list of servers from an external source URL.
But if your are rolling your own a better answer maybe SSH and consider a SSH library for Java
If you consider using an external API look into using JSCAPE's SSH Factory for Java. Documentation can be located here.
I am creating a few JAX-WS endpoints, for which I want to save the received and sent messages for later inspection. To do this, I am planning to save the messages (XML files) into filesystem, in some sensible hierarchy. There will be hundreds, even thousands of files per day. I also need to store metadata for each file.
I am considering to put the metadata (just a couple of fields) into database table, but the XML file content itself into files in a filesystem in order not to bloat the database with content data (that is seldomly read).
Is there some simple library that helps me in saving, loading, deleting etc. the files? It's not that tricky to implement it myself, but I wonder if there are existing solutions? Just a simple library that already provides easy access to filesystem (preferrably over different operating systems).
Or do I even need that, should I just go with raw/custom Java?
Is there some simple library that
helps me in saving, loading, deleting
etc. the files? It's not that tricky
to implement it myself, but I wonder
if there are existing solutions? Just
a simple library that already provides
easy access to filesystem (preferrably
over different operating systems).
Java API
Well, if what you need to do is really simple, you should be able to achieve your goal with java.io.File (delete, check existence, read, write, etc.) and a few stream manipulations with FileInputStream and FileOutputStream.
You can also throw in Apache commons-io and its handy FileUtils for a few more utility functions.
Java is independent of the OS. You just need to make sure you use File.pathSeparator, or use the constructor File(File parent, String child) so that you don't need to explicitly mention the separator.
The Java file API is relatively high-level to abstract the differences of the many OS. Most of the time it's sufficient. It has some shortcomings only if you need some relatively OS-specific feature which is not in the API, e.g. check the physical size of a file on the disk (not the the logical size), security rights on *nix, free space/quota of the hard drive, etc.
Most OS have an internal buffer for file writing/reading. Using FileOutputStream.write and FileOutputStream.flush ensure the data have been sent to the OS, but not necessary written on the disk. The Java API support also this low-level integration to manage these buffering issue (example here) for system such as database.
Also both file and directory are abstracted with File and you need to check with isDirectory. This can be confusing, for instance if you have one file x, and one directory /x (I don't remember exactly how to handle this issue, but there is a way).
Web service
The web service can use either xs:base64Binary to pass the data, or use MTOM (Message Transmission Optimization Mechanism) if files are large.
Transactions
Note that the database is transactional and the file system not. So you might have to add a few checks if operations fails and are re-tried.
You could go with a complicated design involving some form of distributed transaction (see this answer), or try to go with a simpler design that provides the level of robustness that you need. A possible design could be:
Update. If the user wants to overwrite a file, you actually create a new one. The level of indirection between the logical file name and the physical file is stored in database. This way you never overwrite a physical file once written, to ensure rollback is consistent.
Create. Same story when user want to create a file
Delete. If the user want to delete a file, you do it only in database first. A periodic job polls the file system to identify files which are not listed in database, and removes them. This two-phase deletes ensures that the delete operation can be rolled back.
This is not as robust as writting BLOB in real transactional database, but provide some robustness. You could otherwise have a look at commons-transaction, but I feel like the project is dead (2007).
There is DataNucleus, a Java persistence provider. It is little too heavy for this case, but it supports JPA and JDO java standards with different datastores (RDBMS, object storage, XML, JSON, Excel, etc.). If the product is already using JPA or JDO, it might be worth considering using NataNucleus, as saving data into different datastores should be transparent. I suppose DataNucleus supports splitting the data into several files, creating the sensible directory/file structure I wanted (in my question), but this is just a guess.
Support for XML and JSON seems to be experimental.