Index: FragmentLoader.java =================================================================== RCS file: /home/cvs/jasig/portal/source/org/jasig/portal/layout/alm/tool/FragmentLoader.java,v retrieving revision 1.2 diff -u -r1.2 FragmentLoader.java --- FragmentLoader.java 4 May 2005 19:52:42 -0000 1.2 +++ FragmentLoader.java 18 Jul 2005 05:55:45 -0000 @@ -13,6 +13,7 @@ import java.util.Map; import java.util.Set; import java.util.Iterator; +import java.util.StringTokenizer; import javax.xml.transform.TransformerFactory; import javax.xml.transform.sax.SAXTransformerFactory; @@ -394,9 +395,57 @@ } } else { String restrName=ai.getValue("name"); + + String priority = ai.getValue("value"); if(restrName!=null) { + + if (restrName.equals("priority") + && priority.equals("") ) { + System.out.println("ERROR: Invalid priority. Priority is empty."); + System.exit(1); + } + + StringTokenizer st = new StringTokenizer(priority, "-"); + + if (st.countTokens() == 2) { + String minPriority = st.nextToken(); + String maxPriority = st.nextToken(); + + + int minPriorityInt = 0; + try { + minPriorityInt = Integer.parseInt(minPriority); + } catch (NumberFormatException nfe) { + System.out.println("ERROR: Illegal min priority, wasn't an integer: [" + + minPriority + "], in priority range [" + priority + "]"); + System.exit(1); + } + + int maxPriorityInt = 0; + try { + maxPriorityInt = Integer.parseInt(maxPriority); + } catch (NumberFormatException nfe) { + System.out.println("ERROR: Illegal max priority, wasn't an integer: [" + + maxPriority + "], in priority range [" + priority + "]"); + System.exit(1); + } + + if (minPriorityInt > maxPriorityInt) { + System.out.println("ERROR: Illegal priority range [" + + priority + "]: min (" + minPriority + + ") is greater than max (" + maxPriority + ")."); + System.exit(1); + } + + } + + ai.addAttribute(uri,"type","type","CDATA",restrName); } else { + // restrName was null, so the following error message isn't correct, is it? + // isn't the problem that the config file fails to define a restriction name at all + // (restrName is null), rather than that the file specifies an unregistered + // restriction name? System.out.println("ERROR: config file specifies a restriction name \""+restrName+"\" which is not registered with the database!"); System.exit(1); }