Replaced some deprecated methods

This commit is contained in:
Chris Parker 2020-02-24 23:51:41 -06:00
parent 76eded0d9d
commit 93d34d781a
15 changed files with 26 additions and 21 deletions

View File

@ -13,7 +13,7 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import org.apache.commons.lang3.text.StrSubstitutor; import org.apache.commons.text.StringSubstitutor;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -438,7 +438,7 @@ public class DBExtensionTestUtils {
substitutes.put("dbName", dbConfig.getDatabaseName()); substitutes.put("dbName", dbConfig.getDatabaseName());
substitutes.put("useSSL", dbConfig.isUseSSL()); substitutes.put("useSSL", dbConfig.isUseSSL());
String urlTemplate = "jdbc:${dbType}://${host}:${port}/${dbName}?useSSL=${useSSL}"; String urlTemplate = "jdbc:${dbType}://${host}:${port}/${dbName}?useSSL=${useSSL}";
StrSubstitutor strSub = new StrSubstitutor(substitutes); StringSubstitutor strSub = new StringSubstitutor(substitutes);
return strSub.replace(urlTemplate); return strSub.replace(urlTemplate);
} }

View File

@ -318,6 +318,11 @@
<artifactId>commons-collections</artifactId> <artifactId>commons-collections</artifactId>
<version>3.2.2</version> <version>3.2.2</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.8</version>
</dependency>
<dependency> <dependency>
<groupId>commons-validator</groupId> <groupId>commons-validator</groupId>
<artifactId>commons-validator</artifactId> <artifactId>commons-validator</artifactId>

View File

@ -450,7 +450,7 @@ public abstract class ProjectManager {
ObjectNode node = (ObjectNode)jsonObj; ObjectNode node = (ObjectNode)jsonObj;
if (node.get("name").asText("").equals(placeHolderJsonObj.get("name").asText(""))) { if (node.get("name").asText("").equals(placeHolderJsonObj.get("name").asText(""))) {
found = true; found = true;
node.put("display", placeHolderJsonObj.get("display")); node.set("display", placeHolderJsonObj.get("display"));
break; break;
} }
} }

View File

@ -112,8 +112,8 @@ public class LoadLanguageCommand extends Command {
if (translations != null) { if (translations != null) {
try { try {
ObjectNode node = ParsingUtilities.mapper.createObjectNode(); ObjectNode node = ParsingUtilities.mapper.createObjectNode();
node.put("dictionary", translations); node.set("dictionary", translations);
node.put("lang", new TextNode(bestLang)); node.set("lang", new TextNode(bestLang));
respondJSON(response, node); respondJSON(response, node);
} catch (IOException e) { } catch (IOException e) {
logger.error("Error writing language labels to response stream"); logger.error("Error writing language labels to response stream");
@ -158,7 +158,7 @@ public class LoadLanguageCommand extends Command {
if (value == null) {; if (value == null) {;
value = entry.getValue(); value = entry.getValue();
} }
results.put(code, value); results.set(code, value);
} }
return results; return results;
} }

View File

@ -38,7 +38,7 @@ import java.io.Writer;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.text.StringEscapeUtils;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.google.refine.ProjectManager; import com.google.refine.ProjectManager;
@ -106,7 +106,7 @@ public class HtmlTableExporter implements WriterExporter {
writer.write(StringEscapeUtils.escapeHtml4(cellData.link)); writer.write(StringEscapeUtils.escapeHtml4(cellData.link));
writer.write("\">"); writer.write("\">");
} }
writer.write(StringEscapeUtils.escapeXml(cellData.text)); writer.write(StringEscapeUtils.escapeXml10(cellData.text));
if (cellData.link != null) { if (cellData.link != null) {
writer.write("</a>"); writer.write("</a>");
} }

View File

@ -47,7 +47,7 @@ public class Chomp implements Function {
Object o1 = args[0]; Object o1 = args[0];
Object o2 = args[1]; Object o2 = args[1];
if (o1 != null && o2 != null && o1 instanceof String && o2 instanceof String) { if (o1 != null && o2 != null && o1 instanceof String && o2 instanceof String) {
return StringUtils.chomp((String) o1, (String) o2); return StringUtils.removeEnd((String) o1, (String) o2);
} }
} }
return null; return null;

View File

@ -37,7 +37,7 @@ import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.Properties; import java.util.Properties;
import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.text.StringEscapeUtils;
import com.google.refine.expr.EvalError; import com.google.refine.expr.EvalError;
import com.google.refine.grel.ControlFunctionRegistry; import com.google.refine.grel.ControlFunctionRegistry;

View File

@ -48,7 +48,7 @@ public class SHA1 implements Function {
if (args.length == 1 && args[0] != null) { if (args.length == 1 && args[0] != null) {
Object o = args[0]; Object o = args[0];
String s = (o instanceof String) ? (String) o : o.toString(); String s = (o instanceof String) ? (String) o : o.toString();
return DigestUtils.shaHex(s); return DigestUtils.sha1Hex(s);
} }
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects a string"); return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects a string");
} }

View File

@ -35,7 +35,7 @@ package com.google.refine.expr.functions.strings;
import java.util.Properties; import java.util.Properties;
import org.apache.commons.lang3.text.WordUtils; import org.apache.commons.text.WordUtils;
import com.google.refine.expr.EvalError; import com.google.refine.expr.EvalError;
import com.google.refine.grel.ControlFunctionRegistry; import com.google.refine.grel.ControlFunctionRegistry;

View File

@ -37,7 +37,7 @@ import java.io.UnsupportedEncodingException;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.util.Properties; import java.util.Properties;
import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.text.StringEscapeUtils;
import com.google.refine.expr.EvalError; import com.google.refine.expr.EvalError;
import com.google.refine.grel.ControlFunctionRegistry; import com.google.refine.grel.ControlFunctionRegistry;

View File

@ -47,7 +47,7 @@ import java.util.Map;
import org.apache.poi.ooxml.POIXMLException; import org.apache.poi.ooxml.POIXMLException;
import org.apache.poi.common.usermodel.Hyperlink; import org.apache.poi.common.usermodel.Hyperlink;
import org.apache.poi.hssf.usermodel.HSSFDateUtil; import org.apache.poi.ss.usermodel.DateUtil;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.poifs.filesystem.POIFSFileSystem; import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.ss.usermodel.CellType; import org.apache.poi.ss.usermodel.CellType;
@ -258,8 +258,8 @@ public class ExcelImporter extends TabularImportingParserBase {
} else if (cellType.equals(CellType.NUMERIC)) { } else if (cellType.equals(CellType.NUMERIC)) {
double d = cell.getNumericCellValue(); double d = cell.getNumericCellValue();
if (HSSFDateUtil.isCellDateFormatted(cell)) { if (DateUtil.isCellDateFormatted(cell)) {
value = HSSFDateUtil.getJavaDate(d); value = DateUtil.getJavaDate(d);
// TODO: If we had a time datatype, we could use something like the following // TODO: If we had a time datatype, we could use something like the following
// to distinguish times from dates (although Excel doesn't really make the distinction) // to distinguish times from dates (although Excel doesn't really make the distinction)
// Another alternative would be to look for values < 0.60 // Another alternative would be to look for values < 0.60

View File

@ -89,7 +89,7 @@ public class JsonImporter extends TreeImportingParserBase {
ObjectNode firstFileRecord = fileRecords.get(0); ObjectNode firstFileRecord = fileRecords.get(0);
File file = ImportingUtilities.getFile(job, firstFileRecord); File file = ImportingUtilities.getFile(job, firstFileRecord);
JsonFactory factory = new JsonFactory(); JsonFactory factory = new JsonFactory();
JsonParser parser = factory.createJsonParser(file); JsonParser parser = factory.createParser(file);
PreviewParsingState state = new PreviewParsingState(); PreviewParsingState state = new PreviewParsingState();
JsonNode rootValue = parseForPreview(parser, state); JsonNode rootValue = parseForPreview(parser, state);
@ -223,7 +223,7 @@ public class JsonImporter extends TreeImportingParserBase {
public JSONTreeReader(InputStream is) { public JSONTreeReader(InputStream is) {
try { try {
parser = factory.createJsonParser(is); parser = factory.createParser(is);
current = null; current = null;
next = parser.nextToken(); next = parser.nextToken();
} catch (IOException e) { } catch (IOException e) {

View File

@ -49,7 +49,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.text.StringEscapeUtils;
import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.refine.ProjectMetadata; import com.google.refine.ProjectMetadata;

View File

@ -186,7 +186,7 @@ public class XmlImporter extends TreeImportingParserBase {
} }
if (children.size() > 0) { if (children.size() > 0) {
result.put("c", children); result.set("c", children);
} }
return result; return result;
} }

View File

@ -149,7 +149,7 @@ public class JSONUtilities {
} }
static public void safePut(ObjectNode options, String key, JsonNode rootElement) { static public void safePut(ObjectNode options, String key, JsonNode rootElement) {
options.put(key, rootElement); options.set(key, rootElement);
} }
static public void safeInc(ObjectNode obj, String key) { static public void safeInc(ObjectNode obj, String key) {