Project

General

Profile

Revision e82373d1

IDe82373d124304c336e4c946d47b72ef374814f61
Parent 00fafe2a
Child 5394c18a

Added by Andreas Müller almost 2 years ago

ref #8628 Improve error messages for ORCID parsing

View differences:

cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/agent/ORCID.java
111 111
		if (orcid.startsWith("http:") ){
112 112
		    orcid = orcid.replaceFirst("http:", "https:").trim();  //https is the current display standard
113 113
		}
114
//		Matcher matcher = orcidPattern.matcher(orcid);
115
//		if (matcher.find()){
116
//		    orcid = matcher.replaceFirst("").trim();
117
//		}
118

  
119 114

  
120 115
		//replace URI prefix
121 116
		if (orcid.startsWith(HTTP_ORCID_ORG)){
......
124 119
		    orcid = orcid.replaceFirst(ORCID_ORG, "");
125 120
        }
126 121

  
127

  
128 122
		//now we should have the pure orcid
129 123
		if (orcid.length() != 15 && orcid.length() != 16 && orcid.length() != 18 && orcid.length() != 19){
130 124
			//for persistence reason we currently restrict the length of DOIs to 1000
131
			throw new IllegalArgumentException("ORCIDs must have exactly 16 numbers and 3 dashes ('-').");
125
			throw new IllegalArgumentException("ORCIDs must have exactly 16 digits. 3 dashes ('-') may be included after each group of 4 digits.");
132 126
		}
133 127

  
134 128
		Matcher matcher = orcidPattern.matcher(orcid);
135 129
		if (!matcher.find()){
136
            throw new IllegalArgumentException("ORCID can not be parsed. It must have exactly 16 numbers and 3 dashes ('-').");
130
            throw new IllegalArgumentException("ORCID can not be parsed. It must have exactly 16 digits. 3 dashes ('-') may be included after each group of 4 digits.");
137 131
		}
138 132

  
139 133
		orcid = orcid.replaceAll(UTF8.ANY_DASH_RE(), "");
......
148 142
		    this.baseNumber = orcid;
149 143
		    this.checkSum = checkDigit(baseNumber);
150 144
		}
151

  
152 145
	}
153 146

  
154 147
	private String makeOrcid(){

Also available in: Unified diff

Add picture from clipboard (Maximum size: 40 MB)