Remove StringUtils class and use org.apache.commons.lang.StringUtils instead.
This commit is contained in:
parent
7b93ff82fc
commit
dbeceda47c
21 changed files with 32 additions and 369 deletions
|
@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
@ -14,7 +15,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.ajax.VitroAjaxController;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||
|
||||
|
||||
public class PrimitiveDelete extends VitroAjaxController {
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
@ -14,7 +15,6 @@ import edu.cornell.mannlib.vitro.webapp.controller.ContactMailServlet;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||
|
||||
/**
|
||||
* Controller for comments ("contact us") page
|
||||
|
|
|
@ -14,6 +14,7 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
@ -33,7 +34,6 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Rdf
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.RedirectResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.BreadCrumbsUtil;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.PortalWebUtil;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.Tags;
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.Map;
|
|||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.ServletException;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.lucene.document.Document;
|
||||
|
@ -41,7 +42,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
|||
import edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneIndexFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.FlagMathUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividualTemplateModel;
|
||||
import freemarker.ext.beans.BeansWrapper;
|
||||
import freemarker.template.TemplateModel;
|
||||
|
|
|
@ -5,6 +5,7 @@ package edu.cornell.mannlib.vitro.webapp.controller.freemarker;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
@ -12,8 +13,6 @@ import edu.cornell.mannlib.vitro.webapp.beans.Portal;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||
import freemarker.template.Configuration;
|
||||
|
||||
public class TermsOfUseController extends FreemarkerHttpServlet {
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ public class TestController extends FreemarkerHttpServlet {
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final Log log = LogFactory.getLog(TestController.class);
|
||||
private static final String TEMPLATE_DEFAULT = "test.ftl";
|
||||
private static final String TEMPLATE_DEFAULT = "test1.ftl";
|
||||
|
||||
@Override
|
||||
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.HashSet;
|
|||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
@ -26,8 +27,6 @@ import com.hp.hpl.jena.ontology.SomeValuesFromRestriction;
|
|||
import com.hp.hpl.jena.query.Query;
|
||||
import com.hp.hpl.jena.query.QueryFactory;
|
||||
import com.hp.hpl.jena.query.QuerySolution;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.query.Syntax;
|
||||
import com.hp.hpl.jena.rdf.model.Property;
|
||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
|
@ -53,7 +52,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.pellet.PelletListener;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||
|
||||
public class DataPropertyDaoJena extends PropertyDaoJena implements
|
||||
DataPropertyDao {
|
||||
|
|
|
@ -10,11 +10,11 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.hp.hpl.jena.datatypes.xsd.XSDDatatype;
|
||||
import com.hp.hpl.jena.graph.Node;
|
||||
import com.hp.hpl.jena.ontology.ConversionException;
|
||||
import com.hp.hpl.jena.ontology.OntModel;
|
||||
import com.hp.hpl.jena.ontology.OntProperty;
|
||||
|
@ -26,8 +26,6 @@ import com.hp.hpl.jena.query.QueryExecutionFactory;
|
|||
import com.hp.hpl.jena.query.QueryFactory;
|
||||
import com.hp.hpl.jena.query.QuerySolution;
|
||||
import com.hp.hpl.jena.query.ResultSet;
|
||||
import com.hp.hpl.jena.query.Syntax;
|
||||
import com.hp.hpl.jena.rdf.model.Literal;
|
||||
import com.hp.hpl.jena.rdf.model.Property;
|
||||
import com.hp.hpl.jena.rdf.model.RDFNode;
|
||||
import com.hp.hpl.jena.rdf.model.Resource;
|
||||
|
@ -50,7 +48,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.OntologyDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.event.EditEvent;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||
|
||||
public class ObjectPropertyDaoJena extends PropertyDaoJena implements ObjectPropertyDao {
|
||||
private static final Log log = LogFactory.getLog(ObjectPropertyDaoJena.class.getName());
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.util.Map;
|
|||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.joda.time.DateTime;
|
||||
|
@ -28,7 +29,6 @@ import com.hp.hpl.jena.vocabulary.XSD;
|
|||
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.EditLiteral;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.elements.EditElement;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||
|
||||
public class EditSubmission {
|
||||
private String editKey;
|
||||
|
|
|
@ -21,6 +21,7 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
|
@ -28,7 +29,6 @@ import org.apache.lucene.document.Document;
|
|||
import org.apache.lucene.document.Field;
|
||||
import org.apache.lucene.index.CorruptIndexException;
|
||||
import org.apache.lucene.index.Term;
|
||||
import org.apache.lucene.queryParser.MultiFieldQueryParser;
|
||||
import org.apache.lucene.queryParser.ParseException;
|
||||
import org.apache.lucene.queryParser.QueryParser;
|
||||
import org.apache.lucene.search.BooleanClause;
|
||||
|
@ -42,12 +42,8 @@ import org.apache.lucene.search.TopDocs;
|
|||
import org.apache.lucene.search.WildcardQuery;
|
||||
import org.apache.lucene.util.Version;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.IndividualImpl;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectProperty;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.ObjectPropertyStatement;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.Portal;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClassGroup;
|
||||
|
@ -58,9 +54,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMa
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ExceptionResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.ResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DataPropertyDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassGroupDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||
|
@ -75,8 +69,6 @@ import edu.cornell.mannlib.vitro.webapp.search.lucene.Entity2LuceneDoc;
|
|||
import edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneIndexFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.lucene.LuceneSetup;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.FlagMathUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.Html2Text;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.LinkTemplateModel;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.individual.ListedIndividualTemplateModel;
|
||||
import freemarker.template.Configuration;
|
||||
|
|
|
@ -12,6 +12,7 @@ import javax.servlet.ServletRequest;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.dbcp.BasicDataSource;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
@ -32,7 +33,6 @@ import edu.cornell.mannlib.vitro.webapp.dao.jena.RegeneratingGraph;
|
|||
import edu.cornell.mannlib.vitro.webapp.dao.jena.SDBGraphGenerator;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroJenaModelMaker;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.jena.VitroJenaSDBModelMaker;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||
|
||||
public class JenaDataSourceSetupBase extends JenaBaseDaoCon {
|
||||
|
||||
|
|
|
@ -1,101 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class StringUtils {
|
||||
|
||||
private StringUtils() {
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
public static String capitalize(String s) {
|
||||
return s.substring(0, 1).toUpperCase() + s.substring(1);
|
||||
}
|
||||
|
||||
public static String quote(String s) {
|
||||
return isEmpty(s) ? "" : '"' + s + '"';
|
||||
}
|
||||
|
||||
public static String join(List<?> list, boolean quote, String glue) {
|
||||
|
||||
if (glue == null) {
|
||||
glue = ",";
|
||||
}
|
||||
|
||||
String joinedList = "";
|
||||
|
||||
int count = 0;
|
||||
for (Object o : list) {
|
||||
if (o == null) {
|
||||
continue;
|
||||
}
|
||||
String s = o.toString();
|
||||
if (count > 0) {
|
||||
joinedList += glue;
|
||||
}
|
||||
count++;
|
||||
joinedList += quote ? quote(s) : s;
|
||||
}
|
||||
|
||||
return joinedList;
|
||||
}
|
||||
|
||||
public static String join(List<?> list) {
|
||||
return join(list, false, ",");
|
||||
}
|
||||
|
||||
public static String join(List<?> list, String glue) {
|
||||
return join(list, false, glue);
|
||||
}
|
||||
|
||||
public static String join(String glue, String ...strings) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (String s : strings) {
|
||||
list.add(s);
|
||||
}
|
||||
return join(list, false, glue);
|
||||
}
|
||||
|
||||
public static String join(String[] stringArray, boolean quote, String glue) {
|
||||
return join(Arrays.asList(stringArray), quote, glue);
|
||||
}
|
||||
|
||||
public static String join(String[] stringArray) {
|
||||
return join(Arrays.asList(stringArray));
|
||||
}
|
||||
|
||||
public static String join(String[] stringArray, String glue) {
|
||||
return join(Arrays.asList(stringArray), false, glue);
|
||||
}
|
||||
|
||||
public static String quotedList(List<?> list, String glue) {
|
||||
return join(list, true, glue);
|
||||
}
|
||||
|
||||
public static String quotedList(String[] stringArray, String glue) {
|
||||
return quotedList(Arrays.asList(stringArray), glue);
|
||||
}
|
||||
|
||||
public static boolean isEmpty(String s) {
|
||||
return s == null || s.isEmpty();
|
||||
}
|
||||
|
||||
public static boolean equalsOneOf(String s, String... strings) {
|
||||
|
||||
for (String item : strings) {
|
||||
if (item.equals(s)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static String setNullToEmptyString(String s) {
|
||||
return s == null ? "" : s;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,45 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.utils.view;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||
|
||||
public class DateDisplayUtils {
|
||||
|
||||
public static String getDisplayDate(String date) {
|
||||
String displayDate = null;
|
||||
if (date == null) {
|
||||
return displayDate;
|
||||
}
|
||||
List<String> dateParts = Arrays.asList(date.split("-"));
|
||||
int datePartCount = dateParts.size();
|
||||
switch (datePartCount) {
|
||||
case 2:
|
||||
displayDate = StringUtils.join("/", dateParts.get(1), dateParts.get(0));
|
||||
break;
|
||||
case 3:
|
||||
displayDate = StringUtils.join("/", dateParts.get(1), dateParts.get(2), dateParts.get(0));
|
||||
break;
|
||||
default:
|
||||
displayDate = date;
|
||||
}
|
||||
|
||||
return displayDate;
|
||||
}
|
||||
|
||||
public static String getDisplayDateRange(String startDate, String endDate) {
|
||||
startDate = StringUtils.setNullToEmptyString(startDate);
|
||||
endDate = StringUtils.setNullToEmptyString(endDate);
|
||||
List<String> dates = Arrays.asList(startDate, endDate);
|
||||
return StringUtils.join(dates, " - ");
|
||||
}
|
||||
|
||||
public static String getDisplayDateRangeFromRawDates(String startDate, String endDate) {
|
||||
return getDisplayDateRange(getDisplayDate(startDate), getDisplayDate(endDate));
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -2,14 +2,7 @@
|
|||
|
||||
package edu.cornell.mannlib.vitro.webapp.web;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
@ -17,10 +10,6 @@ import org.apache.commons.logging.LogFactory;
|
|||
import edu.cornell.mannlib.vitro.webapp.beans.Individual;
|
||||
import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.VClassDao;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||
import freemarker.cache.TemplateLoader;
|
||||
import freemarker.template.Configuration;
|
||||
|
||||
/**
|
||||
* Class to find custom class views for individuals
|
||||
|
|
|
@ -10,11 +10,11 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerHttpServlet;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.widgets.Widget;
|
||||
import freemarker.core.Environment;
|
||||
import freemarker.template.SimpleScalar;
|
||||
|
|
|
@ -9,20 +9,18 @@ import java.lang.reflect.Modifier;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.directives.BaseTemplateDirectiveModel;
|
||||
import edu.cornell.mannlib.vitro.webapp.web.templatemodels.BaseTemplateModel;
|
||||
import freemarker.core.Environment;
|
||||
|
@ -210,7 +208,7 @@ public class DumpHelper {
|
|||
typeName = typeName.substring(0,1).toLowerCase() + typeName.substring(1);
|
||||
paramTypeList.add(typeName);
|
||||
}
|
||||
methodName += "(" + StringUtils.join(paramTypeList) + ")";
|
||||
methodName += "(" + StringUtils.join(paramTypeList, ", ") + ")";
|
||||
} else {
|
||||
methodName = methodName.replaceAll("^(get|is)", "");
|
||||
methodName = methodName.substring(0, 1).toLowerCase() + methodName.substring(1);
|
||||
|
|
|
@ -23,6 +23,7 @@ import javax.servlet.jsp.JspWriter;
|
|||
import javax.servlet.jsp.tagext.TagSupport;
|
||||
|
||||
import org.apache.commons.lang.StringEscapeUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.joda.time.DateTime;
|
||||
|
@ -40,14 +41,13 @@ import edu.cornell.mannlib.vitro.webapp.beans.VClass;
|
|||
import edu.cornell.mannlib.vitro.webapp.controller.Controllers;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest;
|
||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.FreemarkerConfigurationLoader;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditSubmission;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.Field;
|
||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.SelectListGenerator;
|
||||
import edu.cornell.mannlib.vitro.webapp.search.beans.ProhibitedFromSearch;
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.StringUtils;
|
||||
import edu.cornell.mannlib.vitro.webapp.dao.DisplayVocabulary;
|
||||
import freemarker.template.Configuration;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,123 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.utils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import edu.cornell.mannlib.vitro.testing.AbstractTestClass;
|
||||
|
||||
public class StringUtilsTest extends AbstractTestClass {
|
||||
|
||||
protected static List<String> stringList = new ArrayList<String>();
|
||||
protected static List<Integer> intList = new ArrayList<Integer>();
|
||||
protected static List<String> stringListWithNulls = new ArrayList<String>();
|
||||
protected static String[] stringArray = {"duck", "goose", "crow"};
|
||||
static {
|
||||
stringList.add("apple");
|
||||
stringList.add("banana");
|
||||
stringList.add("orange");
|
||||
|
||||
intList.add(1);
|
||||
intList.add(2);
|
||||
intList.add(3);
|
||||
|
||||
stringListWithNulls.add("rock");
|
||||
stringListWithNulls.add("paper");
|
||||
stringListWithNulls.add((String)null);
|
||||
stringListWithNulls.add("scissors");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCapitalize() {
|
||||
String s1 = "cat";
|
||||
Assert.assertEquals("Cat", StringUtils.capitalize(s1));
|
||||
|
||||
String s2 = "Cat";
|
||||
Assert.assertEquals(s2, StringUtils.capitalize(s2));
|
||||
|
||||
String s3 = "CAT";
|
||||
Assert.assertEquals(s3, StringUtils.capitalize(s3));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuote() {
|
||||
String s1 = "cat";
|
||||
Assert.assertEquals("\"cat\"", StringUtils.quote(s1));
|
||||
|
||||
String s2 = "";
|
||||
Assert.assertEquals("", StringUtils.quote(s2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJoinNoArgs() {
|
||||
|
||||
Assert.assertEquals("apple,banana,orange", StringUtils.join(stringList));
|
||||
Assert.assertEquals("1,2,3", StringUtils.join(intList));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJoinArgs() {
|
||||
|
||||
// Three args
|
||||
Assert.assertEquals("apple:banana:orange", StringUtils.join(stringList, false, ":"));
|
||||
Assert.assertEquals("\"apple\"|\"banana\"|\"orange\"", StringUtils.join(stringList, true, "|"));
|
||||
Assert.assertEquals("\"apple\",\"banana\",\"orange\"", StringUtils.join(stringList, true, null));
|
||||
Assert.assertEquals("apple,banana,orange", StringUtils.join(stringList, false, null));
|
||||
Assert.assertEquals("apple...banana...orange", StringUtils.join(stringList, false, "..."));
|
||||
|
||||
// Two args
|
||||
Assert.assertEquals("apple - banana - orange", StringUtils.join(stringList, " - "));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJoinWithNulls() {
|
||||
Assert.assertEquals("rock,paper,scissors", StringUtils.join(stringListWithNulls));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJoinWithVarargs() {
|
||||
Assert.assertEquals("apple,banana,orange", StringUtils.join((String)null, "apple", "banana", "orange"));
|
||||
Assert.assertEquals("he/she/it", StringUtils.join("/", "he", "she", "it"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJoinWithEmptyString() {
|
||||
Assert.assertEquals(" - 1990", StringUtils.join(" - ", "", "1990"));
|
||||
Assert.assertEquals("1990 - ", StringUtils.join(" - ", "1990", ""));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testArrayJoin() {
|
||||
Assert.assertEquals("duck,goose,crow", StringUtils.join(stringArray));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testQuotedList() {
|
||||
|
||||
Assert.assertEquals("\"apple\"|\"banana\"|\"orange\"", StringUtils.quotedList(stringList, "|"));
|
||||
Assert.assertEquals("\"apple\",\"banana\",\"orange\"", StringUtils.quotedList(stringList, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsOneOf() {
|
||||
|
||||
String s1 = "cat";
|
||||
Assert.assertTrue(StringUtils.equalsOneOf(s1, "dog", "mouse", "cat", "horse"));
|
||||
Assert.assertTrue(StringUtils.equalsOneOf(s1, "cat"));
|
||||
Assert.assertFalse(StringUtils.equalsOneOf(s1, "dog", "mouse", "horse"));
|
||||
Assert.assertFalse(StringUtils.equalsOneOf(s1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetNullToEmptyString() {
|
||||
Assert.assertEquals("", StringUtils.setNullToEmptyString((String)null));
|
||||
Assert.assertEquals("cat", StringUtils.setNullToEmptyString("cat"));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
/* $This file is distributed under the terms of the license in /doc/license.txt$ */
|
||||
|
||||
package edu.cornell.mannlib.vitro.webapp.utils.view;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import edu.cornell.mannlib.vitro.webapp.utils.view.DateDisplayUtils;
|
||||
|
||||
public class DateDisplayUtilsTest {
|
||||
|
||||
@Test
|
||||
public void testDisplayDate() {
|
||||
String date = "2009-10";
|
||||
Assert.assertEquals("10/2009", DateDisplayUtils.getDisplayDate(date));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDisplayDateRange() {
|
||||
String startRaw = "2010-10-11";
|
||||
String endRaw = "2010-11-09";
|
||||
Assert.assertEquals("10/11/2010 - 11/09/2010", DateDisplayUtils.getDisplayDateRangeFromRawDates(startRaw, endRaw));
|
||||
|
||||
String start1 = "1/2/2010";
|
||||
String end1 = "3/4/2011";
|
||||
Assert.assertEquals("1/2/2010 - 3/4/2011", DateDisplayUtils.getDisplayDateRange(start1, end1));
|
||||
|
||||
String empty = "";
|
||||
Assert.assertEquals("1/2/2010 - ", DateDisplayUtils.getDisplayDateRange(start1, empty));
|
||||
Assert.assertEquals(" - 3/4/2011", DateDisplayUtils.getDisplayDateRange(empty, end1));
|
||||
|
||||
Assert.assertEquals("1/2/2010 - ", DateDisplayUtils.getDisplayDateRange(start1, (String)null));
|
||||
Assert.assertEquals(" - 3/4/2011", DateDisplayUtils.getDisplayDateRange((String)null, end1));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -14,7 +14,7 @@
|
|||
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.VitroRequest"%>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.beans.DataPropertyStatement" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.web.MiscWebUtils"%>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.StringUtils" %>
|
||||
<%@ page import="org.apache.commons.lang.StringUtils" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.FrontEndEditingUtils" %>
|
||||
|
||||
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core"%>
|
||||
|
@ -23,16 +23,14 @@
|
|||
|
||||
<%!
|
||||
private String getInputType(String propertyName) {
|
||||
String inputType = StringUtils.equalsOneOf(propertyName, "blurb", "description") ? "textarea" : "text";
|
||||
String inputType = ( propertyName.equals("blurb") || propertyName.equals("desription") ) ? "textarea" : "text";
|
||||
return inputType;
|
||||
}
|
||||
String thisPage = "defaultVitroNsPropForm.jsp";
|
||||
String inThisPage = " in " + thisPage;
|
||||
|
||||
%>
|
||||
<%
|
||||
org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("edu.cornell.mannlib.vitro.jsp.edit.forms." + thisPage);
|
||||
log.debug("Starting " + thisPage);
|
||||
org.apache.log4j.Logger log = org.apache.log4j.Logger.getLogger("edu.cornell.mannlib.vitro.jsp.edit.forms.defaultVitroNsPropForm.jsp");
|
||||
log.debug("Starting defaultVitroNsPropForm.jsp");
|
||||
|
||||
VitroRequest vreq = new VitroRequest(request);
|
||||
WebappDaoFactory wdf = vreq.getWebappDaoFactory();
|
||||
|
@ -49,7 +47,7 @@
|
|||
|
||||
Individual subject = (Individual)vreq.getAttribute("subject");
|
||||
if( subject == null ) {
|
||||
throw new Error("In " + thisPage + ", could not find subject " + subjectUri);
|
||||
throw new Error("In defaultVitroNsPropForm.jsp, could not find subject " + subjectUri);
|
||||
}
|
||||
|
||||
Model model = (Model)application.getAttribute("jenaOntModel");
|
||||
|
@ -62,17 +60,17 @@
|
|||
|
||||
rangeDatatypeUri = dps.getDatatypeURI();
|
||||
if (rangeDatatypeUri == null) {
|
||||
log.debug("no range datatype uri set on vitro namespace property statement for property " + predicateUri + inThisPage);
|
||||
log.debug("no range datatype uri set on vitro namespace property statement for property " + predicateUri + "in defaultVitroNsPropForm.jsp");
|
||||
} else {
|
||||
log.debug("range datatype uri of [" + rangeDatatypeUri + "] on vitro namespace property statement for property " + predicateUri + inThisPage);
|
||||
log.debug("range datatype uri of [" + rangeDatatypeUri + "] on vitro namespace property statement for property " + predicateUri + "in defaultVitroNsPropForm.jsp");
|
||||
}
|
||||
|
||||
rangeLang = dps.getLanguage();
|
||||
if( rangeLang == null ) {
|
||||
log.debug("no language attribute on vitro namespace property statement for property " + predicateUri + inThisPage);
|
||||
log.debug("no language attribute on vitro namespace property statement for property " + predicateUri + "in defaultVitroNsPropForm.jsp");
|
||||
rangeLang = "";
|
||||
} else {
|
||||
log.debug("language attribute of ["+rangeLang+"] on vitro namespace property statement for property " + predicateUri + inThisPage);
|
||||
log.debug("language attribute of ["+rangeLang+"] on vitro namespace property statement for property " + predicateUri + "in defaultVitroNsPropForm.jsp");
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@ -88,12 +86,12 @@
|
|||
// Create list of validators
|
||||
ArrayList<String> validatorList = new ArrayList<String>();
|
||||
if (predicateUri.equals(VitroVocabulary.LABEL) || predicateUri.equals(VitroVocabulary.RDF_TYPE)) {
|
||||
validatorList.add("nonempty");
|
||||
validatorList.add("\"nonempty\"");
|
||||
}
|
||||
if (!StringUtils.isEmpty(rangeDatatypeUriJson)) {
|
||||
validatorList.add("datatype:" + rangeDatatypeUriJson);
|
||||
validatorList.add("\"datatype:" + rangeDatatypeUriJson + "\"");
|
||||
}
|
||||
vreq.setAttribute("validators", StringUtils.quotedList(validatorList, ","));
|
||||
vreq.setAttribute("validators", StringUtils.join(validatorList, ","));
|
||||
|
||||
%>
|
||||
|
||||
|
@ -177,9 +175,9 @@
|
|||
String title = actionText + "<em>" + propertyLabel + "</em> for " + subject.getName();
|
||||
|
||||
String inputType = getInputType(propertyName);
|
||||
log.debug(propertyName + " needs input type " + inputType + inThisPage);
|
||||
log.debug(propertyName + " needs input type " + inputType + "in defaultVitroNsPropForm.jsp");
|
||||
boolean useTinyMCE = inputType.equals("textarea");
|
||||
log.debug( (useTinyMCE ? "" : "not ") + "using tinyMCE to edit " + propertyName + inThisPage);
|
||||
log.debug( (useTinyMCE ? "" : "not ") + "using tinyMCE to edit " + propertyName + "in defaultVitroNsPropForm.jsp");
|
||||
|
||||
%>
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditSubmission" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.controller.Controllers" %>
|
||||
<%@ page import="edu.cornell.mannlib.vitro.webapp.utils.StringUtils" %>
|
||||
<%@ page import="org.apache.commons.lang.StringUtils" %>
|
||||
<%@page import="org.apache.commons.logging.Log"%>
|
||||
<%@page import="org.apache.commons.logging.LogFactory"%>
|
||||
<%@page import="com.hp.hpl.jena.rdf.model.ResourceFactory"%>
|
||||
|
|
Loading…
Add table
Reference in a new issue