Skip to content

Commit

Permalink
Merge pull request IQSS#7801 from poikilotherm/6070-commons-lang3
Browse files Browse the repository at this point in the history
6070 Update Apache Commons Lang3
  • Loading branch information
kcondon authored May 21, 2021
2 parents b95ba34 + 4a13f15 commit a875db7
Show file tree
Hide file tree
Showing 95 changed files with 317 additions and 180 deletions.
4 changes: 3 additions & 1 deletion checkstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@
<property name="excludes" value="lombok,java.util,org.springframework.web.bind.annotation"/>
</module>
-->
<!-- <module name="IllegalImport"/> --> <!-- defaults to sun.* packages -->
<module name="IllegalImport">
<property name="illegalPkgs" value="org.apache.commons.lang"/>
</module>
<!-- <module name="RedundantImport"/> -->
<!-- <module name="UnusedImports">
<property name="processJavadoc" value="false"/>
Expand Down
26 changes: 22 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<postgresql.version>42.2.19</postgresql.version>
<aws.version>1.11.762</aws.version>
<commons.logging.version>1.2</commons.logging.version>
<commons.lang3.version>3.12.0</commons.lang3.version>
<httpcomponents.client.version>4.5.5</httpcomponents.client.version>
<junit.version>4.13.1</junit.version>
<junit.jupiter.version>5.7.0</junit.jupiter.version>
Expand Down Expand Up @@ -120,6 +121,11 @@
<artifactId>commons-logging</artifactId>
<version>${commons.logging.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>${commons.lang3.version}</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
Expand Down Expand Up @@ -318,9 +324,14 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.6</version>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
<!-- Some utils from commons.lang have been moved to commons-text (especially escapeHtml()) -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.9</version>
</dependency>
<dependency>
<groupId>org.apache.solr</groupId>
Expand Down Expand Up @@ -794,12 +805,19 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<version>3.1.2</version>
<configuration>
<configLocation>checkstyle.xml</configLocation>
<encoding>UTF-8</encoding>
<consoleOutput>true</consoleOutput>
</configuration>
<dependencies>
<dependency>
<groupId>com.puppycrawl.tools</groupId>
<artifactId>checkstyle</artifactId>
<version>8.42</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
Expand Down Expand Up @@ -175,7 +175,7 @@ public static String getMetadataFromDvObject(String identifier, Map<String, Stri
metadataTemplate.setAuthors(dataset.getLatestVersion().getDatasetAuthors());
if (dvObject.isInstanceofDataset()) {
//While getDescriptionPlainText strips < and > from HTML, it leaves '&' (at least so we need to xml escape as well
String description = StringEscapeUtils.escapeXml(dataset.getLatestVersion().getDescriptionPlainText());
String description = StringEscapeUtils.escapeXml10(dataset.getLatestVersion().getDescriptionPlainText());
if (description.isEmpty() || description.equals(DatasetField.NA_VALUE)) {
description = AbstractGlobalIdServiceBean.UNAVAILABLE;
}
Expand All @@ -185,7 +185,7 @@ public static String getMetadataFromDvObject(String identifier, Map<String, Stri
DataFile df = (DataFile) dvObject;
//Note: File metadata is not escaped like dataset metadata is, so adding an xml escape here.
//This could/should be removed if the datafile methods add escaping
String fileDescription = StringEscapeUtils.escapeXml(df.getDescription());
String fileDescription = StringEscapeUtils.escapeXml10(df.getDescription());
metadataTemplate.setDescription(fileDescription == null ? AbstractGlobalIdServiceBean.UNAVAILABLE : fileDescription);
String datasetPid = df.getOwner().getGlobalId().asString();
metadataTemplate.setDatasetIdentifier(datasetPid);
Expand All @@ -198,7 +198,7 @@ public static String getMetadataFromDvObject(String identifier, Map<String, Stri
String title = dvObject.getCurrentName();
if(dvObject.isInstanceofDataFile()) {
//Note file title is not currently escaped the way the dataset title is, so adding it here.
title = StringEscapeUtils.escapeXml(title);
title = StringEscapeUtils.escapeXml10(title);
}

if (title.isEmpty() || title.equals(DatasetField.NA_VALUE)) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/edu/harvard/iq/dataverse/DataCitation.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
import javax.xml.stream.XMLStreamWriter;

import edu.harvard.iq.dataverse.util.BundleUtil;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;

/**
*
Expand Down Expand Up @@ -643,7 +643,7 @@ private String formatString(String value, boolean escapeHtml, String wrapperFron

private String formatString(String value, boolean escapeHtml, String wrapperStart, String wrapperEnd) {
if (!StringUtils.isEmpty(value)) {
return new StringBuilder(wrapperStart).append(escapeHtml ? StringEscapeUtils.escapeHtml(value) : value)
return new StringBuilder(wrapperStart).append(escapeHtml ? StringEscapeUtils.escapeHtml4(value) : value)
.append(wrapperEnd).toString();
}
return null;
Expand All @@ -655,7 +655,7 @@ private String formatURL(String text, String url, boolean html) {
}

if (html && url != null) {
return "<a href=\"" + url + "\" target=\"_blank\">" + StringEscapeUtils.escapeHtml(text) + "</a>";
return "<a href=\"" + url + "\" target=\"_blank\">" + StringEscapeUtils.escapeHtml4(text) + "</a>";
} else {
return text;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import javax.persistence.Query;
import javax.persistence.StoredProcedureQuery;
import javax.persistence.TypedQuery;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang3.RandomStringUtils;

/**
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/harvard/iq/dataverse/DataFileTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;

/**
*
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/harvard/iq/dataverse/DatasetField.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;

@Entity
@ValidateDatasetFieldType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import edu.harvard.iq.dataverse.util.BundleUtil;
import java.util.Collections;
import java.util.List;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import java.util.regex.Pattern;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;

/**
*
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/edu/harvard/iq/dataverse/DatasetPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.commons.lang3.mutable.MutableBoolean;
import org.apache.commons.io.IOUtils;

Expand Down Expand Up @@ -3107,8 +3107,8 @@ public void updateFileCounts(){
private List<String> getSuccessMessageArguments() {
List<String> arguments = new ArrayList<>();
String dataverseString = "";
arguments.add(StringEscapeUtils.escapeHtml(dataset.getDisplayName()));
dataverseString += " <a href=\"/dataverse/" + selectedDataverseForLinking.getAlias() + "\">" + StringEscapeUtils.escapeHtml(selectedDataverseForLinking.getDisplayName()) + "</a>";
arguments.add(StringEscapeUtils.escapeHtml4(dataset.getDisplayName()));
dataverseString += " <a href=\"/dataverse/" + selectedDataverseForLinking.getAlias() + "\">" + StringEscapeUtils.escapeHtml4(selectedDataverseForLinking.getDisplayName()) + "</a>";
arguments.add(dataverseString);
return arguments;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import javax.persistence.Query;
import javax.persistence.StoredProcedureQuery;
import javax.persistence.TypedQuery;
import org.apache.commons.lang.RandomStringUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.ocpsoft.common.util.Strings;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/harvard/iq/dataverse/DatasetVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import javax.validation.constraints.Size;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.List;
import java.util.Set;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import edu.harvard.iq.dataverse.util.BundleUtil;
import java.util.Arrays;
import java.util.Date;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.solr.client.solrj.SolrServerException;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/harvard/iq/dataverse/Dataverse.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.NotEmpty;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;

/**
*
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/edu/harvard/iq/dataverse/DataversePage.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@
import javax.ejb.EJBException;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.apache.commons.lang3.StringUtils;
import org.primefaces.PrimeFaces;
import org.primefaces.event.TransferEvent;

Expand Down Expand Up @@ -805,8 +805,8 @@ public String saveLinkedDataverse() {

private List<String> getSuccessMessageArguments() {
List<String> arguments = new ArrayList<>();
arguments.add(StringEscapeUtils.escapeHtml(dataverse.getDisplayName()));
String linkString = "<a href=\"/dataverse/" + linkingDataverse.getAlias() + "\">" + StringEscapeUtils.escapeHtml(linkingDataverse.getDisplayName()) + "</a>";
arguments.add(StringEscapeUtils.escapeHtml4(dataverse.getDisplayName()));
String linkString = "<a href=\"/dataverse/" + linkingDataverse.getAlias() + "\">" + StringEscapeUtils.escapeHtml4(linkingDataverse.getDisplayName()) + "</a>";
arguments.add(linkString);
return arguments;
}
Expand Down Expand Up @@ -867,7 +867,7 @@ public String saveSavedSearch() {
commandEngine.submit(cmd);

List<String> arguments = new ArrayList<>();
String linkString = "<a href=\"/dataverse/" + linkingDataverse.getAlias() + "\">" + StringEscapeUtils.escapeHtml(linkingDataverse.getDisplayName()) + "</a>";
String linkString = "<a href=\"/dataverse/" + linkingDataverse.getAlias() + "\">" + StringEscapeUtils.escapeHtml4(linkingDataverse.getDisplayName()) + "</a>";
arguments.add(linkString);
String successMessageString = BundleUtil.getStringFromBundle("dataverse.saved.search.success", arguments);
JsfHelper.addSuccessMessage(successMessageString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import edu.harvard.iq.dataverse.dataaccess.DataAccess;
import javax.persistence.MappedSuperclass;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;

/**
* A {@link DvObject} that can contain other {@link DvObject}s.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import javax.persistence.NonUniqueResultException;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.ocpsoft.common.util.Strings;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
import javax.faces.event.FacesEvent;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.mutable.MutableBoolean;
import org.primefaces.PrimeFaces;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/harvard/iq/dataverse/Guestbook.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import javax.persistence.Transient;

import edu.harvard.iq.dataverse.util.DateUtil;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.text.StringEscapeUtils;
import org.hibernate.validator.constraints.NotBlank;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/edu/harvard/iq/dataverse/GuestbookPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
import net.handle.hdllib.PublicKeyAuthenticationInfo;
import net.handle.hdllib.ResolutionRequest;
import net.handle.hdllib.Util;
import org.apache.commons.lang.NotImplementedException;
import org.apache.commons.lang3.NotImplementedException;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
import javax.inject.Inject;
import javax.inject.Named;
import javax.servlet.http.HttpServletRequest;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import javax.faces.view.ViewScoped;
import javax.inject.Inject;
import javax.inject.Named;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import javax.inject.Named;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.primefaces.event.SelectEvent;
import org.primefaces.event.ToggleSelectEvent;
import org.primefaces.event.UnselectEvent;
Expand Down
Loading

0 comments on commit a875db7

Please sign in to comment.