Project

General

Profile

« Previous | Next » 

Revision 5741

Added by berkley about 14 years ago

made this method more robust

View differences:

src/edu/ucsb/nceas/metacat/accesscontrol/AccessControlList.java
636 636
    /* Get the int value of READ, WRITE, CHMOD or ALL. */
637 637
	public static int intValue(String permission) {
638 638
	    
639
		int thisPermission = 0;
639
		int thisPermission = -1;
640 640
		try
641 641
		{
642 642
		    thisPermission = new Integer(permission).intValue();
643
		    if(thisPermission >= 0 && thisPermission <= 7)
644
		    {
645
		        return thisPermission;
646
		    }
647
		    else
648
		    {
649
		        thisPermission = -1;
650
		    }
643 651
		}
644 652
		catch(Exception e)
645
		{
653
		{ //do nothing.  this must be a word
646 654
		}
647 655
		
648 656
		if (permission.toUpperCase().contains(CHMODSTRING)) {
......
658 666
			thisPermission |= ALL;
659 667
		}
660 668

  
661
		if (thisPermission == 0) {
662
			return -1;
663
		} else {
664
			return thisPermission;
665
		}
669
		return thisPermission;
666 670
	}
667 671
  
668 672
  /* Get the text value of READ, WRITE, CHMOD or ALL. */

Also available in: Unified diff