Sunday, December 12, 2010

Testing Groovy/Grails with Jargon

I'm having a great time looking at Groovy and Grails as a rapid development environment for iRODS web interfaces via the new Jargon API I am developing.

Jargon is a pure Java API that encapsulates the iRODS server protocol. I am developing a new version, and one of the goals is to make it more usable in Spring-based apps. I have web projects to develop, and at the same time, I need to kick the tires on how Jargon works with dynamic scripting languages. So far, so good. I'm able to wire together some simple things, and utilize the Jargon libraries quite smoothly. Here's a little bit of wiring together of IRODSFileSystem using Spring DSL:

beans = {

irodsFileSystem(org.irods.jargon.core.pub.IRODSFileSystem) {
bean ->
bean.factoryMethod = "instance"
bean.singleton = true
}


irodsFileServiceWrapperService(mydrop.IrodsFileServiceWrapperService) {
irodsFileSystem = ref("irodsFileSystem")
}

irodsAuthenticationHelperService(mydrop.IRODSAuthenticationHelperService) {
irodsFileServiceWrapperService = ref("irodsFileServiceWrapperService")
}

}





Here's a bit of my hacked auth code (I need to see how to more formally wire in Spring Security with Grails:

IrodsFileServiceWrapperService irodsFileServiceWrapperService

/**
* Validate the user by logging into iRODS under the given credentials. Also retrieve the iRODS user groups for
* use in role-based access
* @param host
* @param port
* @param zone
* @param userName
* @param password
* @param resource
* @return
*/
def authenticate(String host, int port, String zone, String userName, String password, String resource) throws AuthenticationException {
def irodsAccount = IRODSAccount.instance(host, port, userName, password, resource, zone, "")
def irodsFileSystem = irodsFileServiceWrapperService.getIrodsFileSystem()
def irodsAccountAuthenticationManager = new IRODSAccountAuthenticationManager()
irodsAccountAuthenticationManager.setIrodsAccessObjectFactory irodsFileSystem.getIRODSAccessObjectFactory()
def irodsAuthentication = new IRODSAuthenticationToken(irodsAccount)
def irodsAuthenticationToken = irodsAccountAuthenticationManager.authenticate(irodsAuthentication)
SecurityContextHolder.getContext().setAuthentication(irodsAuthenticationToken);
}



I'm certain that this is not the most beautiful Grails code, but it's promising nevertheless.

Tuesday, October 26, 2010

Peeking at iRODS XML packing instructions using icommands

In working on the Jargon API, I'm often comparing the protocol operations with icommands. A helpful tip to turn on XML logging of the icommands you are executing:

type this at the command prompt before issuing your commands to set some environment variables:

export irodsProt=1; export irodsLogLevel=9;

Wednesday, October 20, 2010

Hover highlighting for drag and drop in a Swing JTree

This was a pain in the butt. I am working on a file browser for iRODS that allows easy movement of data from local file system to iRODS resources. I'm implementing drag-and-drop gestures of all sorts, and the Swing JTree is pretty bare-bones, and lacked hover highlighting when dragging.

I found a very helpful thread here, pertaining to Swing JTables, but I found it easily adaptable to JTree, adding an alpha background color to the original code. In my subclass of JTree, in which I implement DropTargetListener, I added this


class {

private int highlightedRow = -1;
private Rectangle dirtyRegion = null;
private Color highlightColor = new Color(Color.BLUE.getRed(), Color.BLUE.getGreen(), Color.BLUE.getBlue(), 100);


...


@Override
public void dragOver(DropTargetDragEvent dtde) {

Point location = dtde.getLocation();
int closestRow = this.getClosestRowForLocation((int) location.getX(), (int) location.getY());
boolean highlighted = false;

Graphics g = getGraphics();

// row changed

if (highlightedRow != closestRow) {
if (null != dirtyRegion) {
paintImmediately(dirtyRegion);
}

for (int j = 0; j
if (closestRow == j) {

Rectangle firstRowRect = getRowBounds(closestRow);
this.dirtyRegion = firstRowRect;
g.setColor(highlightColor);

g.fillRect((int) dirtyRegion.getX(), (int) dirtyRegion.getY(), (int) dirtyRegion.getWidth(), (int) dirtyRegion.getHeight());
highlightedRow = closestRow;
}
}

}


...

@Override
public void dragExit(DropTargetEvent dte) {
if (null != dirtyRegion) {
paintImmediately(dirtyRegion);
}
}


}

}

Wednesday, October 14, 2009

Sun VirtualBox

A few quick tips on Sun VirtualBox, their open virtualization platform. I'm runing a host with Windows XP, and I want to host some Linux servers for various purposes (more on that later).

Anyhow, a few quick hits. First, I installed VirtualBox, and immediately went for Fedora 11 from RedHat. Never could get Fedora to see the virtual drives I had created. I switched from Fedora 11 to the latest version of Ubuntu and it works fine.

Second, I was working on creating a shared folder on my Windows host that could be seen by the Linux box, using the provided command:

mount -t vboxsf [-o OPTIONS] sharename mountpoint


This was returning an error that it did not know about vboxsf as a type. I found that the 'missing' step was, once you install the 'Guest Additions', to issue the following command on your guest Linux server...

sudo /media/cdrom/VBoxLinuxAdditions-x86.run

This will let Ubuntu know about the vboxsf type.

I'm liking VirtualBox so far, it appears to be a useful tool in the toolbox.

Wednesday, July 8, 2009

Google Chrome OS?

Since forever in web time the chatter has been about a new 'web OS' from Google. With the advent of rich internet applications in the form of GMail, Google Documents, Calendar, etc we're seeing the migration of information to the web, followed by the migration of the application to the web as a service.

Look at the information habits of people around you, we're relying on portable devices to access the bits of information relevant to time and space, and taking much smaller bites out of the apple..search for a gas station with the lowest price, find the number to a good plumber, send a text message to the baby-sitter. It only makes sense to re-think the relationship of all of these types of applications to the traditional desktop or laptop, or at least Google thinks so..

From Google...

So today, we're announcing a new project that's a natural extension of Google Chrome — the Google Chrome Operating System. It's our attempt to re-think what operating systems should be.

The Chrome OS is targeted first towards small notebooks (and probably tablets?) The post makes it clear that ChromeOS and Android are separate concerns, though a good deal of overlap is acknowledged. Certainly the services that would be consumed by Android are the same services that a typical 'notebook' computer would want, and many of us would treat a notebook and smart phone as interchangable for many tasks.

Intermittantly connected (a-la Gears) rich internet applications will be a key application delivery mode, whether in the form of widgets, or in full-blown browser-based applications. Combine this with a growing number of cloud services running on big grids, and maybe a web OS makes sense?

Monday, June 8, 2009

Note to self...

I just wasted a few minutes on the obvious...Working on a JavaScript with Dojo, going through the excellent Mastering Dojo book from the Pragmatic Programmers.

I'm working on the script, and looking at this bit of code:

dojo.addOnLoad(function() {
dojo.connect(dojo.byId("qform"), "submit", function(e){
//stop default processing and propagation
//(we really don't want to submit the form)
dojo.stopEvent(e);

//erase any previous borders...
dojo.query("*", "fixture").style("border", "");

//set all elements found by the query to have a red border...
var query= dojo.byId("query").value;
dojo.query(query, "fixture").style("border", "2px solid red");
});
});

The error I'm getting is in the 'addOnLoad' method, with a "dojo not defined" error. Looking further up, I indeed have my dojo root specified.

See the problem? Of course not, because there is not a problem with this code. I was looking at the code (mismatched parens? missing semi-colon) when the issue was that I had retrieved the page by putting the file name in the browser, instead of the the http URL, so my code was not being served by my Apache server, therefore making it impossible to find the dojo code. Switch to an http url, and it works like a charm.

Someone is going to make the same mistake, and it's an object lesson (no pun intended) that sometimes there IS a simple solution, but that solution is often overlooked. I hope to save you a few minutes scratching your head.

Friday, June 5, 2009

Come into my office

This is just a bit of fun....click here to read about my 'office' and visit it via the Unity browser plug-in! Good weekend to all.

While I'm pimping...here's my 'other life', my band Good Rocking Sam.