Skip to content

Commit

Permalink
SAK-32320 org.sakaiproject.util.StringUtil.trimToNullLower() -> org.a…
Browse files Browse the repository at this point in the history
…pache.commons.lang3.StringUtils.trimToNullLower() (sakaiproject#4073)
  • Loading branch information
axxter99 authored and ern committed Mar 13, 2017
1 parent 58ce756 commit b47e567
Show file tree
Hide file tree
Showing 21 changed files with 102 additions and 60 deletions.
4 changes: 4 additions & 0 deletions admin-tools/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
<groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>
<build>
<resources>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.lang3.StringUtils;
import org.sakaiproject.alias.api.Alias;
import org.sakaiproject.alias.api.AliasService;
import org.sakaiproject.authz.api.AuthzGroup;
Expand Down Expand Up @@ -78,7 +79,6 @@
import org.sakaiproject.user.api.UserNotDefinedException;
import org.sakaiproject.user.cover.UserDirectoryService;
import org.sakaiproject.util.ResourceLoader;
import org.sakaiproject.util.StringUtil;
import org.sakaiproject.util.Validator;

/**
Expand Down Expand Up @@ -125,9 +125,9 @@ public AdminSitesAction() {
protected List readResourcesPage(SessionState state, int first, int last)
{
// search?
String search = StringUtil.trimToNull((String) state.getAttribute(STATE_SEARCH));
String siteId = StringUtil.trimToNull((String) state.getAttribute(STATE_SEARCH_SITE_ID));
String userId = StringUtil.trimToNull((String) state.getAttribute(STATE_SEARCH_USER_ID));
String search = StringUtils.trimToNull((String) state.getAttribute(STATE_SEARCH));
String siteId = StringUtils.trimToNull((String) state.getAttribute(STATE_SEARCH_SITE_ID));
String userId = StringUtils.trimToNull((String) state.getAttribute(STATE_SEARCH_USER_ID));

// Boolean userOnly = (Boolean) state.getAttribute(STATE_SEARCH_USER);

Expand Down Expand Up @@ -180,9 +180,9 @@ else if (search != null)
protected int sizeResources(SessionState state)
{
// search?
String search = StringUtil.trimToNull((String) state.getAttribute(STATE_SEARCH));
String siteId = StringUtil.trimToNull((String) state.getAttribute(STATE_SEARCH_SITE_ID));
String userId = StringUtil.trimToNull((String) state.getAttribute(STATE_SEARCH_USER_ID));
String search = StringUtils.trimToNull((String) state.getAttribute(STATE_SEARCH));
String siteId = StringUtils.trimToNull((String) state.getAttribute(STATE_SEARCH_SITE_ID));
String userId = StringUtils.trimToNull((String) state.getAttribute(STATE_SEARCH_USER_ID));

// search for non-user sites, using the criteria
if (siteId != null)
Expand Down Expand Up @@ -1097,7 +1097,7 @@ public void doSave_edit(RunData data, Context context)
Site site = (Site) state.getAttribute("site");
if (site != null)
{
String url_alias = StringUtil.trimToNull(data.getParameters().getString("url_alias"));
String url_alias = StringUtils.trimToNull(data.getParameters().getString("url_alias"));
// set an alias for the site
if(url_alias!=null)
{
Expand Down Expand Up @@ -1366,18 +1366,18 @@ public void doCancel_remove(RunData data, Context context)
private boolean readSiteForm(RunData data, SessionState state)
{
// read the form
String id = StringUtil.trimToNull(data.getParameters().getString("id"));
String title = StringUtil.trimToNull(data.getParameters().getString("title"));
String type = StringUtil.trimToNull(data.getParameters().getString("type"));
String shortDescription = StringUtil.trimToNull(data.getParameters().getString("shortDescription"));
String description = StringUtil.trimToNull(data.getParameters().getString("description"));
String id = StringUtils.trimToNull(data.getParameters().getString("id"));
String title = StringUtils.trimToNull(data.getParameters().getString("title"));
String type = StringUtils.trimToNull(data.getParameters().getString("type"));
String shortDescription = StringUtils.trimToNull(data.getParameters().getString("shortDescription"));
String description = StringUtils.trimToNull(data.getParameters().getString("description"));
boolean joinable = data.getParameters().getBoolean("joinable");
String joinerRole = StringUtil.trimToNull(data.getParameters().getString("joinerRole"));
String icon = StringUtil.trimToNull(data.getParameters().getString("icon"));
String info = StringUtil.trimToNull(data.getParameters().getString("info"));
String joinerRole = StringUtils.trimToNull(data.getParameters().getString("joinerRole"));
String icon = StringUtils.trimToNull(data.getParameters().getString("icon"));
String info = StringUtils.trimToNull(data.getParameters().getString("info"));
boolean published = data.getParameters().getBoolean("published");
boolean softlyDeleted = data.getParameters().getBoolean("softlyDeleted");
String skin = StringUtil.trimToNull(data.getParameters().getString("skin"));
String skin = StringUtils.trimToNull(data.getParameters().getString("skin"));
boolean pubView = data.getParameters().getBoolean("pubView");
boolean customOrder = data.getParameters().getBoolean("customOrder");

Expand Down Expand Up @@ -1958,7 +1958,7 @@ private boolean readPageForm(RunData data, SessionState state)
SitePage page = (SitePage) state.getAttribute("page");

// read the form
String title = StringUtil.trimToNull(data.getParameters().getString("title"));
String title = StringUtils.trimToNull(data.getParameters().getString("title"));
page.setTitle(title);

try
Expand Down Expand Up @@ -2029,7 +2029,7 @@ private boolean readSitePropertiesForm(RunData data, SessionState state) {
for (Iterator i = props.getPropertyNames(); i.hasNext();)
{
String name = (String) i.next();
String formValue = StringUtil.trimToNull(data.getParameters().getString("param_" + name));
String formValue = StringUtils.trimToNull(data.getParameters().getString("param_" + name));

// update the properties or remove
if (formValue != null)
Expand All @@ -2043,10 +2043,10 @@ private boolean readSitePropertiesForm(RunData data, SessionState state) {
}

// see if there's a new one
String formName = StringUtil.trimToNull(data.getParameters().getString("new_name"));
String formName = StringUtils.trimToNull(data.getParameters().getString("new_name"));
if (formName != null)
{
String formValue = StringUtil.trimToNull(data.getParameters().getString("new_value"));
String formValue = StringUtils.trimToNull(data.getParameters().getString("new_value"));
if (formValue != null)
{
props.addProperty(formName, formValue);
Expand All @@ -2071,7 +2071,7 @@ private boolean readPagePropertiesForm(RunData data, SessionState state) {
for (Iterator i = props.getPropertyNames(); i.hasNext();)
{
String name = (String) i.next();
String formValue = StringUtil.trimToNull(data.getParameters().getString("param_" + name));
String formValue = StringUtils.trimToNull(data.getParameters().getString("param_" + name));

// update the properties or remove
if (formValue != null)
Expand All @@ -2085,10 +2085,10 @@ private boolean readPagePropertiesForm(RunData data, SessionState state) {
}

// see if there's a new one
String formName = StringUtil.trimToNull(data.getParameters().getString("new_name"));
String formName = StringUtils.trimToNull(data.getParameters().getString("new_name"));
if (formName != null)
{
String formValue = StringUtil.trimToNull(data.getParameters().getString("new_value"));
String formValue = StringUtils.trimToNull(data.getParameters().getString("new_value"));
if (formValue != null)
{
props.addProperty(formName, formValue);
Expand All @@ -2115,7 +2115,7 @@ private boolean readToolPropertiesForm(RunData data, SessionState state) {
for (Enumeration iParams = tool.getPlacementConfig().propertyNames(); iParams.hasMoreElements();)
{
String paramName = (String) iParams.nextElement();
String formValue = StringUtil.trimToNull(data.getParameters().getString("param_" + paramName));
String formValue = StringUtils.trimToNull(data.getParameters().getString("param_" + paramName));

// update the properties or remove
if (formValue != null)
Expand All @@ -2129,10 +2129,10 @@ private boolean readToolPropertiesForm(RunData data, SessionState state) {
}
}
// see if there's a new one
String formName = StringUtil.trimToNull(data.getParameters().getString("new_name"));
String formName = StringUtils.trimToNull(data.getParameters().getString("new_name"));
if (formName != null)
{
String formValue = StringUtil.trimToNull(data.getParameters().getString("new_value"));
String formValue = StringUtils.trimToNull(data.getParameters().getString("new_value"));
if (formValue != null)
{
tool.getPlacementConfig().setProperty(formName, formValue);
Expand All @@ -2154,10 +2154,10 @@ private boolean readGroupForm(RunData data, SessionState state)
Group group = (Group) state.getAttribute("group");

// read the form
String title = StringUtil.trimToNull(data.getParameters().getString("title"));
String title = StringUtils.trimToNull(data.getParameters().getString("title"));
group.setTitle(title);

String description = StringUtil.trimToNull(data.getParameters().getString("description"));
String description = StringUtils.trimToNull(data.getParameters().getString("description"));
group.setDescription(description);

if (title == null)
Expand Down Expand Up @@ -2429,7 +2429,7 @@ public void doSearch_site_id(RunData runData, Context context)
state.removeAttribute(STATE_SEARCH_USER_ID);

// read the search form field into the state object
String search = StringUtil.trimToNull(runData.getParameters().getString(FORM_SEARCH_SITEID));
String search = StringUtils.trimToNull(runData.getParameters().getString(FORM_SEARCH_SITEID));

// set the flag to go to the prev page on the next list
if (search != null)
Expand All @@ -2454,7 +2454,7 @@ public void doSearch_user_id(RunData runData, Context context)
state.removeAttribute(STATE_SEARCH_USER_ID);

// read the search form field into the state object
String search = StringUtil.trimToNull(runData.getParameters().getString(FORM_SEARCH_USERID));
String search = StringUtils.trimToNull(runData.getParameters().getString(FORM_SEARCH_USERID));

// set the flag to go to the prev page on the next list
if (search != null)
Expand Down Expand Up @@ -2500,11 +2500,11 @@ private boolean readToolForm(RunData data, SessionState state)
ToolConfiguration tool = (ToolConfiguration) state.getAttribute("tool");

// read the form
String title = StringUtil.trimToNull(data.getParameters().getString("title"));
String title = StringUtils.trimToNull(data.getParameters().getString("title"));
tool.setTitle(title);

// read the layout hints
String hints = StringUtil.trimToNull(data.getParameters().getString("layoutHints"));
String hints = StringUtils.trimToNull(data.getParameters().getString("layoutHints"));
if (hints != null)
{
// strip all whitespace
Expand All @@ -2523,7 +2523,7 @@ private boolean readToolForm(RunData data, SessionState state)
String value = data.getParameters().getString(formName);
if (value != null)
{
value = StringUtil.trimToNull(value);
value = StringUtils.trimToNull(value);

// if we have a value
if (value != null)
Expand Down Expand Up @@ -2662,9 +2662,9 @@ private void setSiteAlias(String alias, String siteReference, SessionState state
addAlert(state, rb.getFormattedMessage("sitedipag.alias.isinval", new Object[]{alias}));
M_log.warn(this + ".updateSiteInfo: " + rb.getFormattedMessage("sitedipag.alias.isinval", new Object[]{alias}));
}
else if (StringUtil.trimToNull(alias) != null && StringUtil.trimToNull(siteReference) != null)
else if (StringUtils.trimToNull(alias) != null && StringUtils.trimToNull(siteReference) != null)
{
String currentAlias = StringUtil.trimToNull(getSiteAlias(siteReference));
String currentAlias = StringUtils.trimToNull(getSiteAlias(siteReference));

if (currentAlias == null || !currentAlias.equals(alias))
{
Expand Down
4 changes: 4 additions & 0 deletions announcement/announcement-impl/impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
<groupId>org.sakaiproject.site</groupId>
<artifactId>sakai-mergedlist-util</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.sakaiproject.alias.api.Alias;
Expand Down Expand Up @@ -1239,7 +1239,7 @@ public Map<String, String> transferCopyEntitiesRefMigrator(String fromContext, S
}

// not to import any assignment-generated announcement
String assignmentReference = StringUtil.trimToNull(oMessage.getProperties().getProperty(AnnouncementService.ASSIGNMENT_REFERENCE));
String assignmentReference = StringUtils.trimToNull(oMessage.getProperties().getProperty(AnnouncementService.ASSIGNMENT_REFERENCE));
if (toBeImported && assignmentReference != null)
{
toBeImported = false;
Expand Down
4 changes: 4 additions & 0 deletions assignment/assignment-impl/impl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
import org.apache.commons.lang.exception.ExceptionUtils;
import org.sakaiproject.assignment.impl.sort.AnonymousSubmissionComparator;
Expand Down Expand Up @@ -4475,8 +4475,8 @@ public byte[] getGradesSpreadsheet(String ref) throws IdUnusedException, Permiss
@SuppressWarnings("deprecation")
public Collection<Group> getSubmitterGroupList(String searchFilterOnly, String allOrOneGroup, String searchString, String aRef, String contextString) {
Collection<Group> rv = new ArrayList<Group>();
allOrOneGroup = StringUtil.trimToNull(allOrOneGroup);
searchString = StringUtil.trimToNull(searchString);
allOrOneGroup = StringUtils.trimToNull(allOrOneGroup);
searchString = StringUtils.trimToNull(searchString);
boolean bSearchFilterOnly = "true".equalsIgnoreCase(searchFilterOnly);
try
{
Expand Down Expand Up @@ -5182,9 +5182,9 @@ protected void zipGroupSubmissions(String assignmentReference, String assignment
sheet.addRow(gs.getGroup().getTitle(), gs.getGroup().getId(), submitters2String,
s.getGradeDisplay(), s.getTimeSubmittedString(), latenessStatus);

if (StringUtil.trimToNull(submitterString) != null)
if (StringUtils.trimToNull(submitterString) != null)
{
submittersName = submittersName.concat(StringUtil.trimToNull(submitterString));
submittersName = submittersName.concat(StringUtils.trimToNull(submitterString));
submittedText = s.getSubmittedText();

submittersName = submittersName.concat("/");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

import org.apache.commons.lang3.StringUtils;
import org.sakaiproject.entity.api.Entity;

import org.sakaiproject.util.StringUtil;
Expand Down Expand Up @@ -192,9 +193,9 @@ protected void zipWithFlushing(boolean flushing)
submittersName = root;
String submittersString = "test user " + count;

if (StringUtil.trimToNull(submittersString) != null)
if (StringUtils.trimToNull(submittersString) != null)
{
submittersName = submittersName.concat(StringUtil.trimToNull(submittersString));
submittersName = submittersName.concat(StringUtils.trimToNull(submittersString));

try
{
Expand Down
4 changes: 4 additions & 0 deletions assignment/assignment-tool/tool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
import java.util.zip.*;

import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.poi.hssf.usermodel.HSSFRow;
Expand Down Expand Up @@ -12209,7 +12209,7 @@ public boolean readGradeForm(RunData data, SessionState state, String gradeOptio
User[] _users = submission.getSubmitters();
HashMap<String,String> scaledValues = new HashMap<String,String>();
for (int i=0; _users != null && i < _users.length; i++) {
String ug = StringUtil.trimToNull(params.getCleanString(GRADE_SUBMISSION_GRADE + "_" + _users[i].getId()));
String ug = StringUtils.trimToNull(params.getCleanString(GRADE_SUBMISSION_GRADE + "_" + _users[i].getId()));
if ("null".equals(ug)) ug = null;
if (!hasChange && typeOfGrade != Assignment.UNGRADED_GRADE_TYPE) {
hasChange = valueDiffFromStateAttribute(state, ug, submission.getGradeForUser(_users[i].getId()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ public static String fullReference(String root, String relative)
* @param value
* The string to trim.
* @return value trimmed of blanks, and if nothing left, made null.
* @deprecated use commons-lang StringUtils.trimToNull
* @deprecated use commons-lang3 StringUtils.trimToNull
*/
public static String trimToNull(String value)
{
Expand Down
4 changes: 4 additions & 0 deletions search/search-tool/tool/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<dependency>
<groupId>jmock</groupId>
<artifactId>jmock</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.commons.lang3.StringUtils;
import org.sakaiproject.authz.api.SecurityService;
import org.sakaiproject.component.api.ServerConfigurationService;
import org.sakaiproject.exception.IdUnusedException;
Expand Down Expand Up @@ -482,7 +483,7 @@ protected String[] getAllUsersSites() {
protected String[] extractSiteIdsFromProperties(Properties props) {
// Properties props = extractPropertiesFromTool();

String targetSiteId = StringUtil.trimToNull(props.getProperty(SEARCH_SITE_IDS));
String targetSiteId = StringUtils.trimToNull(props.getProperty(SEARCH_SITE_IDS));
if (targetSiteId == null) return new String[] {""};
String[] searchSiteIds = StringUtil.split(targetSiteId, ",");
for(int i = 0;i<searchSiteIds.length;i++){
Expand Down
4 changes: 4 additions & 0 deletions site/mergedlist-util/util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,9 @@
<groupId>org.sakaiproject.velocity</groupId>
<artifactId>sakai-velocity-tool</artifactId>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
</dependencies>
</project>
Loading

0 comments on commit b47e567

Please sign in to comment.