Showing posts from October, 2011

Automating Attachments process in Openbravo and the Newton's third law of Motion

Newton at times gets it right. I love his third law of motion. It’s the Newton’s third law that inspired to do something about which I am posting now. I had to work on a Excel processing scenario where data in the form of excel was to be transmitted between Openbravo and another legacy System (I prefer to call .N**  applications legacy systems). Filling the * is left to your imagination.

For data import, I first thought to create an import process like this, but then it was a day to day transaction, so thought it was not so efficient for auditing process. So I decided to use the Openbravo Attachments. So the user uploads an excels and saves the record and I process it accordingly. Part 1 complete. The next stage was creating a report for legacy system and providing it to the user. First I generated it in a particular drive and then users would access it. That was not proving to be good due to many access issues. Then I tried to create a File Dialog reference that would sa…

Creation and Deletion of folders in Java

Think the program is self-explanatory. Please write to me if I have missed anything or if you have any more doubts.

 * @author shankar
//This Program will illustrate how to create and delete folders using Java code
public class JavaApplication1 {

    public static void main(String[] args) {
            //Mention the folder to be created in the constructor
            //The entire file structure will be created
            File folder = new File("G:/tempfolder/temp1");
            folder.mkdirs(); //this will create the entire File structure if it does not exists

            File folder1= new File("G:/tempfolder/temp1/temp2"); 
            folder1.mkdir(); //this will create the last folder alone if the corresponding path exists

            boolean value = folder1.delete(); // this will delete the temp2 folder alone
                System.out.println("File Deleted");

How to process XML File in java

I had an requirement to parse an incoming SOAP Message object and do certain manipulations over it. I had to do it outside the web service route, so there was no SOAP related process methods available for me. All I had was a xml file in the Input Stream.

I searched a lots of link for xml processing, used many libraries most of which I do not even remember the  name. Then my colleague and another contributor to these blogs suggested to use the DOM Parser provided by default in java. Though it was little confusing in the beginning, with the help of couple of other blogs, we managed to complete it without any external libraries. I have attached the code and the xml file content for your reference.

XML File
Name : test.xml

<?xml version="1.0" encoding="UTF-8"?>
<S:Envelope xmlns:S="">
        <ns2:RegisterComplaint xmlns:ns2="http://webservice/">

Using shell script for day today functions

Yesterday I wrote a post about creating a basic shell script. Today I will present a sample file that I use daily and how it could be more useful. As soon as I open my system, these are the applications that I start.
1. Google Chrome : First Gmail, cricinfo and then hootsuite (my social network client)
2. Thunderbird : My Email Client for official mails
3. Apcahe Tomcat
4. Folders

I use my shell script to do all these tasks at a single command (or even double-click which I usually do not prefer..;) )
This is how my shell script looks:

echo "Starting Apps"
google-chrome &
echo "Chrome Started"
thunderbird &
echo "Thunderbird Started"
sudo /home/shaan/apache/bin/
echo "Tomcat Started"
Note after google-chrome i use space separator for opening multiple tabs in chrome.  Cool isn't it? Write back to me what all shell scripts you use in your daily life.


How to write a simple shell script file

A shell script is the windows equivalent for a batch file. Script files are mainly used to automate tasks or run a series of command with out constant user interaction. There were once really famous way to run automated tasks. There are many GUI based applications that have replaced them, but they have still not lost their charm. Let us see here how to write a simple shell script file. As in all cases, let us say hello to the world..;)

1. Open a simple editor. Create a new file . "sh" is the extension for shell scripts.
2. The first line in any shell script should be, #!/bin/sh . This is used to indicate to the Operating System the type of the file to be processed.
3.  "echo" is a simple command that is used to print values of variables or static content on the console as output. As we wanted to say hello to the world, our second line will be echo "Hello World".

Done. Yes. We are done with our first shell script code. If I was not wrong, th…