Stephan Schwab

Software development and farm life

Archive for January 2010

Hauling a tree with the Jeep

leave a comment »

This is another piece of the long story about the access road to the farm. Or better it is about finding the right path for it. As mentioned before we’ve been given a lot of advice and recommendations but as always it makes a huge difference who tells you what for which purpose. As we don’t want to be stupid and spend money on things we don’t need, we’ve done several attempts at this. Due to the legal issues we’ve had we could not start working on the farm itself. So we had time to spend on proper investigations of other things including the access road.

After our visit last Sunday I’m glad that we were forced to wait. Now it is perfectly clear how to proceed once all the paperwork has been straightened out.

The road or path crosses two farms and we approached the owners after we explored on horseback how it looks like. Here in Panama you have the right to walk over someone else’s land on foot or on horseback. Of course if there is a fence, you have to respect that. If there is a door with a lock, you can’t open that on your own. But if you encounter a regular farm gate without a lock, then you can open it and are supposed to close it, if there is no lock on it. That’s for people on foot or riding a horse. I am not sure about the rules for vehicle access and at the very least I think it’s a matter of tact to ask in advance.

Because of that and because we wanted to know whether in fact this path is an official servidumbre we met with the owner of the land in question. It turns out that he is a very reasonable person with some inclination to help the community. He allows peons to cultivate food on his land knowing that these people have needs to support their families. We learned that he is in the process of obtaining a property title for his land that is currently held under the rights of possession law and in fact the path in question is marked in his property map as official servidumbre. The term servidumbre means something like access road and according to Panamanian law you cannot title land that has no official access road. A servidumbre by law has to be 12 meters wide.

After we learned the good news we set off to enter the path with the Jeep. Our goal was to see the last 300 meters of the path that we were not able to see last time due to a field full of maiz that was blocking our way.

But first we had to remove a tree that was blocking the road. Thanks to our Stihl MS650 chainsaw it only took a minute to cut the tree in half and then we used the Jeep to haul away the log. For the time being we didn’t bother to haul it off the road completely – just enough to get by it.

Once we actually start using this road to get in and out of our farm we will have to maintain it together with other users. There is no public entity reponsable for that. You have to do it and of course you do it in a way that is sufficient for you. Thanks to the Jeep and our special offroad trailer we don’t require much :-)

Written by Stephan Schwab

January 26, 2010 at 3:14 pm

Posted in Farm Life

Setting a specific HTTP return code in Tapestry event handlers

leave a comment »

Java web frameworks help a lot in creating web applications. They abstract away a of the details of the HTTP protocol and if you use a component based framework, you get even more abstraction and pre-canned solutions for many tasks. As these frameworks are created to help in application development these employ a subset of HTTP features and sometimes do things that are contradictory or at least not very helpful to SEO (Search Engine Optimization) efforts. I’ve come across such a little detail and had to do some research to figure out how to solve the issue.

SEO is about creating HTML pages that are likely to appear high in the search results for many queries. SEO can be seen as some kind of black magic and in fact there appears to exist some kind of race or competition between search engine developers and SEO agencies. The people behind search engines try to figure out a way to show the most meaningful pages first in the result for query while SEO folks have a monetary interest in making sure that their client’s site gets listed first although it may not hold the most important or authoritative content for a given topic. Once you want to sell something that a lot of other people sell too, it is no longer about the content of your site. It is simply about exposure to more potential customers than others. That is why search engine ranking can have a significant impact on the bottom line.

Little details can make a huge different. One of those little details is how you do an HTTP redirect.

The HTTP protocol knows two status codes for redirects. One is 302 which means the page has been moved temporarily. The other is 301 which means the page has been moved permanently to a different location. You can see that the Web and thus the HTTP protocol was invented as a means to distribute documents. It wasn’t meant as a client-server protocol for applications. A URL defines the location of a document so that you can refer to it in a hyperlink or in another medium such as in an email. Now that we create interactive applications that resemble desktop applications we are stretching all this a bit and new challenges arise.

Search engines still think about the pages of an application as documents. They crawl everything they have access to and build an index of all the textual content. I guess they don’t care whether a page is an article about a product or is a product details page in some kind of product catalog with an order button.

Some search engines highly respect the difference between 302 (moved temporarily) and 301 (moved permanently). If you redirect from http://www.domain.com/app/mypage.html to http://www.domain.com/another/place/mypage.html with a 302 return code, the old URL will stay in their index. You might remove the old document and change other links so that after this is done only the new URL will be indexed. While both documents are available you may get punished for having duplicate content online. If you tell the search engine with a 301 return code (moved permanently) that the old URL won’t come back, it will delete the old URL from its index and no punishment for duplicate content can occur.

So that’s the background of why it is important to be able to set a specific HTTP return code. I had this issue during the development of a web application with the Tapestry web framework and needed to find a clean solution that goes well along with the ideas of a component based framework. Although you can simply resort back to HTTP servlet programming in Tapestry pages it is not really the best idea. It violates separation of concern because doing such stuff in a page class mixes application logic and HTTP protocol handling, may violate Don’t Repeat Yourself (you may need that in more places) and makes testing harder because suddently tests need to deal with all the servlet stuff as well.

After a post on the Tapestry mailing list I got a very helpful reply by Lutz Hühnken who suggested to contribute to Tapestry‘s ComponentEventResultProcessor a new HttpStatusCode class. With that in place one can return an instance of HttpStatusCode from event handlers instead of just strings with the name of a page or a page class object.

Now a line like

return new HttpStatusCode(HttpServletResponse.SC_MOVED_PERMANENTLY, link) ;

solves the problem described above. This redirects the user agent to the URL link with a 301 return code instead of the usual 302 (moved temporarily).

Here is the snippet to contribute to the ComponentEventResultProcessor:

public static void contributeComponentEventResultProcessor(
    MappedConfiguration<Class, ComponentEventResultProcessor> configuration, 
    final Response response) {
  configuration.add(HttpStatusCode.class, new ComponentEventResultProcessor() {
    public void processResultValue(HttpStatusCode value) throws IOException {
	  if (!value.getLocation().isEmpty())
	    response.setHeader("Location", value.getLocation());

	  response.sendError(value.getStatusCode(), "");
    }
  });
}

Written by Stephan Schwab

January 17, 2010 at 12:43 am

Cherimoya fruit was seeded

leave a comment »

Our little tree nursery got a new addition: Cherimoya. Celis, our gardener, seeded some of this fruit tree and brought a few samples. He introduced it to us as Anon which is part of the same family of plants but has a different look.

That’s the main issue with all these tropical plants. Depending on the country the same thing has a dozen names and of course people confuse them too. So you never know what it really is until you research it. ;-)

This is how it looks on the inside:

And this is the outside.

According to what I read this fruit is over ripe. It is ripe when the outside is green and not brownish.

Written by Stephan Schwab

January 14, 2010 at 4:12 pm

Posted in Farm Life

Follow

Get every new post delivered to your Inbox.

Join 138 other followers