Can you add support for when the portal version is not able to be determined?  this code will through NPE if the version isn't valid.  to test this, create a layout template project, and then delete all the project facets config reopen the project and then try again.  This time you wouldn't be able to tell the version.  (or delete the runtime info).  Then try again and make sure the code will work.