Project

General

Profile

Revision 6688

when comparing D1 Subject objects, use the equals() method not direct string comparison
https://redmine.dataone.org/issues/2050

View differences:

test/edu/ucsb/nceas/metacat/dataone/CNodeServiceTest.java
350 350
			sysmeta = CNodeService.getInstance(request).getSystemMetadata(session, guid);
351 351
			assertNotNull(sysmeta);
352 352
			// check it
353
			assertEquals(rightsHolder.getValue(), sysmeta.getRightsHolder().getValue());
353
			assertTrue(rightsHolder.equals(sysmeta.getRightsHolder()));
354 354
			
355 355
        } catch(Exception e) {
356 356
            fail("Unexpected error: " + e.getMessage());
src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
971 971
                  
972 972
                  List<Subject> subjects = node.getSubjectList();
973 973
                  for (Subject subject : subjects) {
974
                     if (subject.getValue().equals(session.getSubject().getValue())) {
974
                     if (subject.equals(session.getSubject())) {
975 975
                         isAllowed = true;
976 976
                         break;
977 977
                     }
src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
146 146
    }
147 147
    Subject subject = session.getSubject();
148 148

  
149
    // be sure the user is authenticated for create()
149
    Subject publicSubject = new Subject();
150
    publicSubject.setValue(Constants.SUBJECT_PUBLIC);
151
	// be sure the user is authenticated for create()
150 152
    if (subject == null || subject.getValue() == null || 
151
        subject.getValue().toLowerCase().equals(Constants.SUBJECT_PUBLIC) ) {
153
        subject.equals(publicSubject) ) {
152 154
      throw new NotAuthorized("1100", "The provided identity does not have " +
153 155
        "permission to WRITE to the Node.");
154 156
      
......
619 621
	    
620 622
    // do we own it?
621 623
    for (Subject s: subjects) {
622
    	allowed = systemMetadata.getRightsHolder().getValue().equals(s.getValue());
624
    	allowed = systemMetadata.getRightsHolder().equals(s);
623 625
    	if (allowed) {
624 626
    		return allowed;
625 627
    	}
......
633 635
	      for (Subject s: subjects) {
634 636
	        //if (accessRule.getSubjectList().contains(s)) {
635 637
        	for (Subject ruleSubject: accessRule.getSubjectList()) {
636
        		if (ruleSubject.getValue().equals(s.getValue())) {
638
        		if (ruleSubject.equals(s)) {
637 639
		          allowed = accessRule.getPermissionList().contains(permission);
638 640
		          if (allowed) {
639 641
		        	  break search; //label break

Also available in: Unified diff