Changeset 5578 for VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/service/impl/ReferenceValidator.java
- Timestamp:
- 08/20/14 11:59:28 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/service/impl/ReferenceValidator.java
r5545 r5578 34 34 public class ReferenceValidator extends AbstractValidator<String> { 35 35 36 private static final Pattern HANDLE_PATTERN = Pattern.compile("^(hdl|doi):[0-9\\.]+\\/.+$"); 36 private static final String HANDLE_SPECIFIC_PART_PATTERN = "[0-9\\.]+\\/.+$"; 37 private static final Pattern HANDLE_PATTERN = Pattern.compile("^(hdl|doi):" + HANDLE_SPECIFIC_PART_PATTERN); 38 private static final Pattern HANDLE_RESOLVER_PATTERN = Pattern.compile("^http://(hdl\\.handle\\.net|dx\\.doi\\.org|)/" + HANDLE_SPECIFIC_PART_PATTERN); 37 39 private final IValidator<String> urlValidator = new UrlValidator(UrlValidator.NO_FRAGMENTS); 38 40 … … 54 56 return validatable.isValid(); 55 57 } 56 58 59 /** 60 * 61 * @param uri 62 * @return true IFF the expression is a URI consisting of a valid handle 63 * pattern preceded by a handle scheme expression (hdl: or doi:) OR one of 64 * the accepted handle resolver base URL's (http://hdl.handle.net or 65 * http://dx.doi.org) 66 */ 57 67 public static boolean isPid(CharSequence uri) { 58 return HANDLE_PATTERN.matcher(uri).matches(); 68 return HANDLE_PATTERN.matcher(uri).matches() 69 || HANDLE_RESOLVER_PATTERN.matcher(uri).matches(); 59 70 } 60 71
Note: See TracChangeset
for help on using the changeset viewer.