Posts

Search and Replace in ODT using AODL

Recently I needed to create a way to search and replace a word in a OpenOffice OpenDocument ODT. It would seem the project itself already has a library AODL (take care, at least two other project pages but with older code) that exposes the format model but I didn't find any utility methods like search and replace functionality. I've created two versions of the method, one a old-style, imperative approach, and the other, a LINQ version. As I'm still new to LINQ it would seem that the classical approach produces a more efficient code. Anyone care to chip in and make a faster algorithm? In this particular version I'm just going for simple string equality, I didn't want to go with other StringComparison methods (just look at the Equals overload method). public static void SearchAndReplaceString(TextDocument document, string searchText, string replaceText) { var content = document.Content; foreach (var item in content) ...

Relaxing SSL validation for JaxWS

I've recently had the need to access a web service developed in .Net and signed with a self signed certificate. I've decided to use the JaxWS and the Metro stack to develop the client and run it on Java6. As a plus, the service was protected with username and password. The service was exposed on an IP address and I repetedly had problems in establishing a connection. In the end, thanks to this article, it was obvious that the certificate was not created with the alternative name attribute but it was not an option to change the certificate as the web service was already used by other consumers (.net clients don't suffer by this issue). So, on my quest to relax the validation, I've found out this article and code snippet, which did not compile at first (I guess package names were changed in JDK6) so I've did some trivial refactoring and now, after invoking the static methods in the client code, the SSL connection gets validated with no problems. Hope it helps and th...

GWT SuggestBoxReloaded

This article will present how to implement a GWT 1.6 (RC2) SuggestBox with backing hidden fields, RPC calls and not query the server on every character event. While integrating GWT on work, I needed to implement a SuggestBox with a backend RPC service but I had some requirements that the default SuggestBox didn't fulfill. Namely, I needed that the suggestion sets hidden fields (ex. displaying a human readable name for the user and setting a hidden id field). The solution presented in GWT SuggestBox backed by DTO Model and the Using the GWT SuggestBox with RPC were very helpful in creating this example project. I advise you to read/implement them before reading further in order to understand the issues. The first article hit the sweet point on how to pass hidden values using the DTO pattern, you can either wrap your hidden fields (Hidden.wrap) or as in this example we'll instantiate them using GWT and add them to the panel. The next issues were following, 1. You need to be abl...

No row with the given identifier exists

I've recently gotten this infamous Exception while doing a HQL query. org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [it.linksystem.csai.model.Operator#3] This was rather strange as the system worked quite well and it successfully retrieved selects on that entity using the Criteria API. Looking on the net, most suggestions and FAQ's point to a different direction. My issue was rather simple mapping error. The entity on which I was doing selects, was referencing an Operator. In my (java) model, Admin inherits from Operator, and both inherit from User. In fact persisting the entities was no problem no matter if the entity persisted was referencing an Admin or Operator. If however there was an instance that referenced an Admin hibernate would launch the Exception if one executed a HQL query (I guess Criteria queries follow a different path to create the select and are immune to this issue). My mistake was that I didn't know you can nest a subcl...

Turning off Asus M50S light sensor

As I've recently gotten this nice laptop, I've found that the light sensor really makes more problems then it solves so I'm shutting it down in both Windows (Fn+A) and in Linux. Under linux all you need to do is: echo 0 > /sys/devices/platform/asus-laptop/ls_switch This fix is valid only for the current session, to persist the settings just install sysfsutils and then in /etc/sysfs.conf put devices/platform/asus-laptop/ls_switch=0

JBuilder 2008 and Windows Vista problems

So let's say you try to install JBuilder 2008 under Windows Vista (32bit). Did all went smoothly? A friend of mine got a nice JVM terminated Exit code=-1 error. It would seem that if you modify the JBuilder.ini -Xmx parameter (initially over 800M) to 700M or 600M and if you run reset_JBuilder.bat it might finish the installation. An alternative is to modify JBuilder.ini the moment it gets created so you don't have to wait twice. Also it would seem sometimes class diagrams won't show classes. My friend deleted all com.ibm.icu* packages and jars under JBuilder and put com.ibm.icu_3.8.1.v20080530.jar from eclipse 3.4 to the jbuilder 2088 plugins directory. For the moment things seem to function.

On HC

As often things go, you sometimes don't notice things that are integral part of your life. Yesterday I was in company with my cousin and his girlfriend and we noticed this weird thing we decided to call HC which stands for hardcore. Basically, its stands for compulsive-obsessive attention to "details" like water drops after washing the dishes, having things clean at all times, not allowing other people to slip up and often venting on them if they make a mistake. Of course like any good HC person I don't consider this things minor details :) The point is, is it a virtue, or is it a problem? Should we vent on other people when they make a mistake, how should we do it? Is it only a symptoms of something much deeper or a better capacity to adapt to harsher conditions of life? Anyhow, on this bright note, if I don't manage to concoct one more blog post for the holidays, I wish you all the best for the New Year 2008 and may all your wishes come true! PS. It won't ha...