Project

General

Profile

« Previous | Next » 

Revision 7315

check for whitespace in identifiers during create() and update()
https://redmine.dataone.org/issues/3047

View differences:

src/edu/ucsb/nceas/metacat/dataone/MNodeService.java
231 231
        }
232 232
        Subject subject = session.getSubject();
233 233

  
234
        // do we have a valid pid?
235
        if (pid == null || pid.getValue().trim().equals("")) {
236
            throw new InvalidRequest("1202", "The provided identifier was invalid.");
237
            
234
        // verify the pid is valid format
235
        if (isValidIdentifier(pid)) {
236
        	throw new InvalidRequest("1202", "The provided identifier is invalid.");
238 237
        }
239 238

  
240 239
        // check for the existing identifier
src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
297 297
      
298 298
    }
299 299
    
300
    // verify the pid is valid format
301
    if (isValidIdentifier(pid)) {
302
    	throw new InvalidRequest("1202", "The provided identifier is invalid.");
303
    }
304
    
300 305
    // verify that pid == SystemMetadata.getIdentifier()
301 306
    logMetacat.debug("Comparing pid|sysmeta_pid: " + 
302 307
      pid.getValue() + "|" + sysmeta.getIdentifier().getValue());
......
949 954
  }
950 955
  
951 956
  /**
957
   * Check fro whitespace in the given pid.
958
   * null pids are also invalid by default
959
   * @param pid
960
   * @return
961
   */
962
  public static boolean isValidIdentifier(Identifier pid) {
963
	  if (pid != null && pid.getValue() != null && pid.getValue().length() > 0) {
964
		  return !pid.getValue().matches("\\s");
965
	  } 
966
	  return false;
967
  }
968
  
969
  
970
  /**
952 971
   * Insert or update an XML document into Metacat
953 972
   * 
954 973
   * @param xml - the XML document to insert or update

Also available in: Unified diff