merging URL validation in defaultLinkForm.jsp

This commit is contained in:
bdc34 2010-07-21 18:44:34 +00:00
parent 30890a7b5f
commit 0b97ec523b
3 changed files with 57 additions and 13 deletions

View file

@ -2,6 +2,19 @@
package edu.cornell.mannlib.vitro.webapp.edit.n3editing;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.hp.hpl.jena.datatypes.RDFDatatype;
import com.hp.hpl.jena.datatypes.TypeMapper;
import com.hp.hpl.jena.ontology.OntModelSpec;
@ -12,13 +25,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.Datatype;
import edu.cornell.mannlib.vitro.webapp.dao.jena.DatatypeDaoJena;
import edu.cornell.mannlib.vitro.webapp.dao.jena.WebappDaoFactoryJena;
import java.util.*;
import java.util.regex.Pattern;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* User: bdc34
* Date: Jan 24, 2008
@ -146,7 +152,7 @@ public class BasicValidation {
return REQUIRED_FIELD_EMPTY_MSG;
}
// Format validation
if("isDate".equalsIgnoreCase(validationType)){
else if("isDate".equalsIgnoreCase(validationType)){
if( isDate( value))
return SUCCESS;
else
@ -160,10 +166,16 @@ public class BasicValidation {
} else {
return errorMsg;
}
}
} else if ("httpUrl".equalsIgnoreCase(validationType)){
//check if it has http or https, we could do more but for now this is all.
if(! value.startsWith("http://") && ! value.startsWith("https://") ){
return "This URL must start with http:// or https://";
}else{
return SUCCESS;
}
}
//Date not past validation
if( "dateNotPast".equalsIgnoreCase(validationType)){
else if( "dateNotPast".equalsIgnoreCase(validationType)){
//if( ! past (value) )
// return "date must not be in the past";
//Current date
@ -239,6 +251,9 @@ public class BasicValidation {
return (value == null || value.trim().length() == 0);
}
private static Pattern urlRX = Pattern.compile("(([a-zA-Z][0-9a-zA-Z+\\-\\.]*:)/{0,2}[0-9a-zA-Z;/?:@&=+$\\.\\-_!~*'()%]+)(#[0-9a-zA-Z;/?:@&=+$\\.\\-_!~*'()%]+)?");
/** we use null to indicate success */
public final static String SUCCESS = null;
@ -253,7 +268,7 @@ public class BasicValidation {
static final List<String> basicValidations;
static{
basicValidations = Arrays.asList(
"nonempty","isDate","dateNotPast" );
"nonempty","isDate","dateNotPast","httpUrl" );
}
private Log log = LogFactory.getLog(BasicValidation.class);