Tuesday, October 30, 2012

Spring's LDAP And/Or Filter Combo

I was just working with Spring's LDAP filters and came into an issue good ol Google couldn't help me with. You have the powerful AndFilter and OrFilter, and all the tutorials explicitly show how to use one or the other. But what if you want to use both?

I was able to solve it with this, if there is an easier way please comment.

public List findUsers(boolean lockedOut, boolean signedAgreement) {
  AndFilter andFilter = new AndFilter();
  OrFilter orFilter = new OrFilter();

  andFilter.and(new EqualsFilter("lockedOut", lockedOut);

  if(signedAgreement) {
    andFilter.and(new EqualsFilter("signedAgreement", signedAgreement);
  } else {
    orFilter.or(new EqualsFilter("signedAgreement", signedAgreement);
    orFilter.or(new NotPresentFilter("signedAgreement");
The main part is the signedAgreement, if its true we just want to add it to the filter to check for the property to be true in LDAP, but if we want to check for False, we want to check if its False OR if its not present at all. This allows us to have both the AND and OR filter.

Wednesday, May 9, 2012

MOZILLA_FIVE_HOME not set (Talend/Ubuntu 12.04)

After upgrading to Ubuntu 12.04 I have been having an issue with Talend's TMAP expression builder. I was unable to edit because I would get a popup error whenever I tried to open it:

org.talend.commons.exception.CommonExceptionHandler  - No more handles [Unknown Mozilla path (MOZILLA_FIVE_HOME not set)]

After some investigation it seems that XulRunner is not installed with 12.04 which is the lead cause for this. After some digging I was able to find a work around, this seems to be a big issue with the Eclipse community. Here are the steps for Ubuntu 64bit:

1. Download the following 64 bit packages:


2. Install with "dpkg --install <filename>"
3. Relaunch Talend.