Ignore:
Timestamp:
08/20/14 11:59:28 (10 years ago)
Author:
Twan Goosen
Message:

Also accepting PID resolver URL's for publication without warning. Added help text explaining PID's.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • VirtualCollectionRegistry/trunk/VirtualCollectionRegistry/src/main/java/eu/clarin/cmdi/virtualcollectionregistry/service/impl/ReferenceValidator.java

    r5545 r5578  
    3434public class ReferenceValidator extends AbstractValidator<String> {
    3535
    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);
    3739    private final IValidator<String> urlValidator = new UrlValidator(UrlValidator.NO_FRAGMENTS);
    3840
     
    5456        return validatable.isValid();
    5557    }
    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     */
    5767    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();
    5970    }
    6071
Note: See TracChangeset for help on using the changeset viewer.