Friday, December 12, 2008

Problem fix in fop 0.20. Hard return not recognized.

Several days ago we had an issue with fop pdf generator. Fop wasn't recognizing hard returns in user comments and putting all of them in one big giant paragraph. It was an annoying problem.

In fop-0.93 there is an easy way to fix this problem:
<fo:block treatment="preserve">


For people who are stuck with fop 0.2 like we are have to use below workaround:


I'm using "splitstring" template to parse value from node "Comments" with pattern "hard return" which is represented by &xD . The strings generated by splitting are displayed in their own fo:block, thus preserving hard returns.

Below is the code.


<xsl:call-template name="splitstring">
<xsl:with-param name="string">
<xsl:value-of select="Comments">
</xsl:value-of>
<xsl:with-param name="pattern">
<xsl:value-of select="'&#xD'">
</xsl:value-of>
</xsl:with-param>



I found split string function here:
http://www.exslt.org/str/functions/split/str.split.template.xsl.html

Code for the same is as below:


<xsl:call-template name="splitstring">
<xsl:with-param name="string">
<xsl:value-of select="Comments">
</xsl:value-of>
<xsl:with-param name="pattern">
<xsl:value-of select="''">
</xsl:value-of>
</xsl:with-param>
<xsl:template name="splitstring">
<xsl:param name="string"/>
<xsl:param name="pattern"/>
<xsl:choose>
<xsl:when test="not($string)" />
<xsl:when test="not($pattern)">
<xsl:call-template name="split-characters">
<xsl:with-param name="string"
select="$string" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="split-pattern">
<xsl:with-param name="string"
select="$string" />
<xsl:with-param name="pattern"
select="$pattern" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>

<xsl:template name="split-characters">
<xsl:param name="string" />
<xsl:if test="$string">
<fo:block>
<xsl:value-of select="substring($string, 1, 1)" />
</fo:block>
<xsl:call-template name="split-characters">
<xsl:with-param name="string"
select="substring($string, 2)" />
</xsl:call-template>
</xsl:if>
</xsl:template>

<xsl:template name="split-pattern">
<xsl:param name="string" />
<xsl:param name="pattern" />
<xsl:choose>
<xsl:when test="contains($string, $pattern)">
<xsl:if test="not(starts-with($string, $pattern))">
<fo:block>
<xsl:value-of select="substring-before($string, $pattern)" />
</fo:block>
</xsl:if>
<xsl:call-template name="split-pattern">
<xsl:with-param name="string"
select="substring-after($string, $pattern)" />
<xsl:with-param name="pattern"
select="$pattern" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<fo:block>
<xsl:value-of select="$string" />
</fo:block>
</xsl:otherwise>
</xsl:choose>
</xsl:template>





Monday, December 8, 2008

My Little one


My little one "Srikar Dontula" 's picture on my new T-mobile blackberry pearl 8100. Blackberry was initially a pain to use. Getting used to it a little bit now. Love it so far....

My first piano recital
















Picture from my first piano recital (12/06/08). I have been taking classes since end of August '08. Recitals will be every 6 months. Will have to see if I can post a video next time around.

Next to me is my teacher Brenda Meether. I take classes at her piano studio. Her web location: http://www.brendameethermusic.com/

SCP transferring files.

Command to upload files to a server:

scp <file-name> user@server-ip <destination-file-name>

ex: scp mail.jar sarat@some-ip mail.jar

[Above puts the file in user's home directory. Specify particular directory if you wish you place file in a different location]

Command to downloading files from a server:

scp user@server-ip:<file-name> <local-directory-location>

ex: scp sarat@some-ip:mail.jar /home/sarat/Desktop/

Thursday, December 4, 2008

Using cadaver for querying webdav

Home page for cadaver: http://www.webdav.org/cadaver/

On ubuntu you can install it from repositories. Below are steps to do the same.
Steps on how to install cadaver from ubuntu repositories.
(i) From System -> Administration -> Synaptic Package Manager -> Type "Cadaver" and hit search.
(ii) Click on checkbox right next to cadaver -> Select mark for installation -> Hit Apply.

Using cadaver: (I looked for documentation on home page and didn't find any. Below steps might help you get started)
1. type in "cadaver" on the command line.
2. open http://< ip-address >/
3. cd ../exchange/some-folder/calendar/ (asked me for credentials)
4. ls - to list files. (was able to list files on webdav)
5. propget file-name.EML (lists propeties)
5. get file-name.EML (gets webpage. shows it on the terminal)
6. propnames test203-1.EML
7. help (to get more help)
8. help command (to list help information) ex:- help ls

Ubuntu x-windows problem fix.

Recently one of our desktop after restart distorted the whole screen.

Tried below steps to solve the problem.

1. Reinstall ubuntu-desktop (didn't work)
sudo apt-get remove ubuntu-desktop (removed ubuntu desktop)
sudo apt-get install ubuntu-desktop (re-installed it)

2. sudo dpkg --configure -a (didn't work)

3. sudo dpkg-reconfigure xserver-xorg (this solved the problem)
After issuing the command went through all configuration screens, selected defaults and rebooted ubuntu to see the login screens undistorted.


Note:
1. From login screen to go to command line use "Ctrl + Alt + F1"
2. To go back to login screen use "Ctrl + Alt + F7"
Looks like ubuntu has 6 tty sessions. F7 takes you to x-windows.

Ubuntu upgrade broke network manager.

My amd 64 network manager broke after today's upgrade. Followed below link to solve the problem

https://bugs.launchpad.net/bugs/279433

Steps:
1. Downloaded: network-manager_0.7~~svn20080928t225540+eni0-0ubuntu2_amd64.deb

from link: https://launchpad.net/ubuntu/intrepid/amd64/network-manager/0.7~~svn20080928t225540+eni0-0ubuntu2

2. Moved existing network-manager deb from /var/cache/apt/archives/ to the desktop

mv /var/cache/apt/archives/network-manager-pptp_0.7~~svn20081015t024626-0ubuntu1.8.10.1_amd64.deb ~/Desktop

3. Copied "network-manager_0.7~~svn20080928t225540+eni0-0ubuntu2_amd64.deb" to /var/cache/apt/archives folder.

4. Restarted the box. Networking started working!!

Wednesday, December 3, 2008

Open source LDAP browser/editor

LDAP BROWSER/EDITOR: http://www-unix.mcs.anl.gov/~gawor/ldap/download.html

JBoss Notes

1. How to install jboss as service in ubuntu:
Create link in /etc/init.d/jboss to /usr/local/jboss/bin/jboss_init_redhat.sh using below command:
ln -s /etc/init.d/jboss /usr/local/jboss/bin/jboss_init_redhat.sh

2. How to bind JBoss to a particular IP address rather than localhost.
(You might be required to do this to call session beans using RMI)
JBOSS Bind Address JAVA_OPTS:
set JAVA_OPTS=%JAVA_OPTS% -Dbind.address=10.10.50.20
link: http://blogs.adobe.com/livecycle/2008/03/livecycle_sample_jboss_runbat.html

3. How to restore JBoss persistence connection rather than restarting:
Under jmx-console for JBoss. Click on below link under "JCA"
name=jdbc/< your database jndi name >,service=ManagedConnectionPool
Click on flush cache button to restore connection to database.

4. Start & Stop JBOSS on solaris
svcadm enable network/jboss:default
svcadm disable network/jboss:default

svcs -l jboss
svcs -p jboss

5. Installing 2nd instance of JBoss.
Description: * default/deploy/jbossweb-tomcat55.sar/server.xml:

o change 8080 to 18080

* default/conf/jboss-service.xml

o change 8083 to 18083
o change 1099 to 11099
o change 1098 to 11098
o change 4445 to 14445
o change 4444 to 14444

* default/conf/jboss-minimal.xml

o change 1099 to 11099
o change 1098 to 11098

* default/deploy/jms/uil2-service.xml

o change 8093 to 18093

Starting hsqldb database

java -classpath lib/hsqldb.jar org.hsqldb.Server

Glassfish Notes

Starting and Stopping a Domain:
./asadmin start-domain < domain-name >

Setting up SQL Server Datasource in glassfish:
jtds class: net.sourceforge.jtds.jdbcx.JtdsDataSource
resource type: javax.sql.ConnectionPoolDataSource

Disabling foreign keys for all tables in a database.

DROP ALL FOREIGN KEYS SQLSERVER:
SELECT
'
' +
CASE WHEN xtype = 'TR' THEN
'Drop Trigger ' + [Name]
ELSE
'ALTER TABLE ' + object_name(parent_obj) + ' DROP FOREIGN KEY ' + [name]
END +
';'
AS Script
from sysobjects where xtype IN ('F','TR')


DISABLE FOREIGN KEYS SQL Server:
EXEC sp_MSforeachtable @command1="ALTER TABLE ? NOCHECK CONSTRAINT ALL"
EXEC sp_MSforeachtable @command1="ALTER TABLE ? DISABLE TRIGGER ALL"

RE-ENABLING FOREIGN KEYS:
EXEC sp_MSforeachtable @command1="ALTER TABLE ? CHECK CONSTRAINT ALL"
EXEC sp_MSforeachtable @command1="ALTER TABLE ? ENABLE TRIGGER ALL"



IN MYSQL:
Just add "sessionVariables=FOREIGN_KEY_CHECKS=0" to your JDBC URL.

Session expired error while deploying icefaces application on TOMCAT.

Session expired errors.
Fix by editing tomcathome/conf/context.xml

Look for below comment in context.xml
Uncomment this to disable session persistence across Tomcat restarts

Uncomment below configuration item
<Manager pathname="" />

AS400 Cheat Sheet.

1. How to view version of AS400:
1. GO LICPGM -> 10 -> F11
2. DSPSFWRSC (display software resources Hit F11 to see version)

2. How to create a new database on AS400 using any sql tool
create collection databasename (new schema command)

3. Clear contens of a file
clrpfm library/filename (clear contents of a file)

4. Get IP address of as400
On the iSeries you can use CFGTCP option 10.

5. View ports being used
NETSTAT from PC or AS400.

6. Kill a program immediately (in QShell) like [kill -9 in unix]
On as400 it is: kill -12

7. ALTER BLOB LENGTH
alter table attachment alter column document set data type blob(10485760)

8. DSPFFD (DISPLAY FULL FILE DESCRIPTION)
DISPLAYS COLUMN LENGTHS AND OTHER INFORMATION ABOUT A FILE.

9. Start QShell on AS400
Command: strqsh

Tuesday, December 2, 2008

Ubuntu Service Management

To disable a startup service use: sudo update-rc.d -f mysql remove
(had to use -f option to force remove)
To make mysql startup when ubuntu boots: sudo update-rc.d mysql defaults

sudo update-rc.d mysql remove
update-rc.d: /etc/init.d/mysql exists during rc.d purge (use -f to force)

sudo update-rc.d -f mysql remove
Removing any system startup links for /etc/init.d/mysql ...
/etc/rc0.d/K21mysql
/etc/rc1.d/K21mysql
/etc/rc2.d/S19mysql
/etc/rc3.d/S19mysql
/etc/rc4.d/S19mysql
/etc/rc5.d/S19mysql
/etc/rc6.d/K21mysql

sudo update-rc.d mysql defaults
Adding system startup for /etc/init.d/mysql ...
/etc/rc0.d/K20mysql -> ../init.d/mysql
/etc/rc1.d/K20mysql -> ../init.d/mysql
/etc/rc6.d/K20mysql -> ../init.d/mysql
/etc/rc2.d/S20mysql -> ../init.d/mysql
/etc/rc3.d/S20mysql -> ../init.d/mysql
/etc/rc4.d/S20mysql -> ../init.d/mysql
/etc/rc5.d/S20mysql -> ../init.d/mysql

This is the link I followed: http://nixcraft.com/shell-scripting/542-ubuntu-linux-control-startup-services-scripts.html

SQL Server Problem Fixes

***************
1. Apostrophe issue in sql statement:

select * from business where name = 'Craig's List';

Above statement fails.

Use Below: Have to replace single apostrophe with two apostrophes.

select * from business where name = 'Craig''s List';

***************


***************
2. Sql statement errors out when there are spaces in column names.

"contact on contractor" is column in contractorconversion table.
"BUSINESS NAME" is another column in contractorconversion table.

To get around use: \"<>\" around the column name.

String sqlStmt = "select cc.\"contact on contractor\" as contact from contractorconversion cc, business b where b.name=cc.\"BUSINESS NAME\" and cc.\"BUSINESS NAME\"=";
***************