Posts

Generating PDF Report using Apache FOP, MS word (for template) and JAVA

Image
Generating PDF Report using Apache FOP, MS word (for template) and JAVA We often encounter the requirement for generating the custom PDF report. There are many open source tools like iText, Jasper etc. I was looking for some approach that ease the formatting task for the report. Will follow below steps to generate the report: For further understanding, we will take a task to generate the sample report. We will generate user bank account statement PDF. As this is the sample PDF, we will include limited details. The logo is We will follow the above mentioned steps: Prepare the report template using MS word. As a part of the bank statement report we will need to include below information in report. Name Address Account Number Bank Name Month Transaction List-> Desc, Credit/Debit, Amount Based on the above mentioned parameter we generated the below PDF template in MS word. Generating this template in MS word and formatting it does not take long time...

Integrate Microsoft Email Webservice Service (EWS) using JAVA

In this post we will see how to integrate the Microsoft Email Webservice (EWS) with JAVA using the open source EWS-JAVA-API.  Download the ews-java-api source code here. ews-java-api I was not able to find the binaries for ews-java-api, thus I build the project using maven. Below lib are need to run the JAVA program: 1. Binary for ews-java-api . 2. jcifs-1.3.17.jar 3. httpcore-4.3.3.jar 4. httpclient-4.3.6.jar 5. commons-logging-1.2.jar 6. commons-codec-1.6.jar 7. commons-cli-1.2.jar Please find the simple program to send the email using MS-EWS. The program is explain with the comments inline. The HTTPS i.e. SSL url is used, there is no need to include the certificate in credential store as the API internally validate the certs. package com; import java.net.URI; import microsoft.exchange.webservices.data.EmailMessage; import microsoft.exchange.webservices.data.ExchangeCredentials; import microsoft.exchange.webservices.data.ExchangeService; import microsoft.exch...

Implementing PGP (Pretty Good Privacy) using Bouncy Castle Crypto APIs

I was just exploring the Java API's for encrypting and decrypting the file using PGP (Pretty Good Privacy), and I came across Bouncy Castle Crypto APIs. Here we will simply see how to use the Bouncy Castle APIs. Firstly download the cypto jar from the bouncy castle site, you can find the links in the end. 1.        Extract the Jar “crypto-145” at   2.      The java classes are at location “.crypto-145\src\org\bouncycastle\openpgp\examples” Use the jar’s at “crypto-145\jars” as per your SDK:- I have used bcpg-jdk16-145.jar and bcprov-jdk16-145.jar You need to first compile the JAVA classes. Lets create the public and private key:- 1. We will use  RSAKeyPairGenerator.java java class to generate the key’s         java org . bouncycastle . openpgp . examples . RSAKeyPairGenerator charlie "open sesame"    ---where            --  Ch...

Dynamic Routing in OSB

Image
In this post we will see how to use OSB dynamic routing feature to Route Request to different proxy/business service at run time.  To demonstrate how Dynamic Routing works, we will first create two proxy service with Mocked response indicating which proxy service got called. We will have customer creation service, which creates the customer either in CRMOD or OCH based on the parameter passed in request. There will be 3 proxy services: 1.      OCH proxy service : a.       URI : /proxy/ ochCreateCustomer This proxy will return the mocked response i.e. “customer created in OCH” 2.      CRMOD proxy service: a.       URI : /proxy/ crmodCreateCustomer This proxy will return the mocked response i.e. “customer created in CRMOD” 3.      Create Customer Orchestration service: a.       URI: /proxy/ createCustomer This p...

Downloading Twits using Twitter Public Stream API

In this post will try to show how to connect to Twitter Public Stream API and download live Twits. We can save these Twits in any format like comma or pipe delimited. These Twits can be use for Data Mining or Data Analysis. Have used this Twits to analyse the current News in given region. This program creates files of 50MB each, and keep rotating till the time the stream is running. we can run Map-Reduce program using Hadoop Framework to analysis the data at much faster rate. Prerequisite: 1. Need to have Twitter Application 2. Twitter OAuth Tokens       https://dev.twitter.com/docs/auth/obtaining-access-tokens 3. Twitter4j Libraries      http://twitter4j.org/en/ Below are the twitter4j API used: TwitterStreamFactory  : This API returns the object of type  TwitterStream We need to set below authorization tokens to connect to Twitter Public Stream. You will find below tokens once you create Twitter Application. -Dtwitter4j.oauth...

Integrating Weblogic with IBM MQ over JMS

Image
We can integrate weblogic with IBM MQ over JMS by creating Foreign JMS server with Links in weblogic server. We need to create .binding file which will acts as file based JNDI provider to create JMS binding to MQ resources. Will first explain how to create .binding file and then will configure weblogic to use the same. Steps to create .binding file: Firstly we need to add below jar’s in CLASSPATH jms.jar com.ibm.mq.jar com.ibm.mqjms.jar jta.jar connector.jar jndi.jar providerutil.jar fscontext.jar Create JMSProperties.config file with below properties INITIAL_CONTEXT_FACTORY=com.sun.jndi.fscontext.RefFSContextFactory PROVIDER_URL=file:/tmp/mqm/jndi SECURITY_AUTHENTICATION=none Run below command ./JMSAdmin -v JMSProperties . config InitCtx> def qcf(ForeignCF) TRANSPORT(CLIENT) HOST(localhost) PORT(1414) CHANNEL(MQCHANNEL) QMGR(MQMRG) def q(MQ1) qmgr(MQMRG) queue(MQ1) def q(MQR1) qmgr(MQMRG) queue(MQR1) display ctx ...