Skip to content

Commit

Permalink
Remove commons-lang lib dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
iroqueta committed Oct 25, 2024
1 parent 14f17c2 commit ddcf060
Show file tree
Hide file tree
Showing 21 changed files with 73 additions and 67 deletions.
6 changes: 3 additions & 3 deletions android/src/main/java/com/genexus/util/GxJsonReader.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;

import org.apache.commons.lang.CharEncoding;
import java.nio.charset.StandardCharsets;

import com.genexus.internet.StringCollection;
import com.google.gson.stream.JsonReader;
Expand All @@ -15,8 +15,8 @@ public class GxJsonReader {

public GxJsonReader(InputStream stream) {
try {
reader = new JsonReader(new InputStreamReader(stream, CharEncoding.UTF_8));
} catch (UnsupportedEncodingException e) {
reader = new JsonReader(new InputStreamReader(stream, StandardCharsets.UTF_8));
} catch (UnsupportedOperationException e) {
//TODO
}
}
Expand Down
5 changes: 0 additions & 5 deletions common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@
<artifactId>commons-codec</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
Expand Down
3 changes: 1 addition & 2 deletions common/src/main/java/com/genexus/BaseProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import java.util.concurrent.ConcurrentHashMap;

import com.genexus.xml.XMLReader;
import org.apache.commons.lang.StringUtils;

import com.genexus.GXSmartCacheProvider.DataUpdateStatus;
import com.genexus.common.classes.AbstractGXFile;
Expand All @@ -27,7 +26,7 @@ public abstract class BaseProvider implements IGXSmartCacheProvider

protected String normalizeKey(String key)
{
if (StringUtils.isNotEmpty(key))
if (CommonUtil.isNotEmpty(key))
return key.toLowerCase();
else
return key;
Expand Down
34 changes: 31 additions & 3 deletions common/src/main/java/com/genexus/CommonUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
import java.text.*;
import java.util.*;

import org.apache.commons.lang.StringUtils;

import java.lang.reflect.*;
import java.security.*;
import java.math.BigInteger;
Expand Down Expand Up @@ -461,7 +459,7 @@ public static boolean contains(String s1, String s2)
}
public static String charAt(String s1, int idx)
{
if (StringUtils.isEmpty(s1) || s1.length() < idx || idx <= 0)
if (isEmpty(s1) || s1.length() < idx || idx <= 0)
return "";
else
return String.valueOf(s1.charAt(idx-1));
Expand Down Expand Up @@ -3220,4 +3218,34 @@ public static String getClassName(String pgmName) {

return classPackage + pgmName.replace('\\', '.').trim();
}

public static boolean isEmpty(String str) {
return str == null || str.isEmpty();
}

public static boolean isNotEmpty(String str) {
return str != null && !str.isEmpty();
}

public static String join(List<String> list, String delimiter) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < list.size(); i++) {
sb.append(list.get(i));
if (i < list.size() - 1) {
sb.append(delimiter);
}
}
return sb.toString();
}

public static String deleteWhitespace(String str) {
if (str == null) {
return null;
}
return str.replaceAll("\\s", "");
}

public static boolean isBlank(String str) {
return str == null || str.trim().isEmpty();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

import java.util.*;

import org.apache.commons.lang.StringUtils;

import com.genexus.CommonUtil;
import com.genexus.ModelContext;
import com.genexus.common.interfaces.SpecificImplementation;
import com.genexus.db.DynamicExecute;
Expand Down Expand Up @@ -671,7 +670,7 @@ public String nextToken()
tk += c;

// Retorna solo si encuentra un token
if (!StringUtils.isEmpty(tk))
if (!CommonUtil.isEmpty(tk))
return tk;
}
else
Expand Down
4 changes: 1 addition & 3 deletions common/src/main/java/com/genexus/xml/XMLWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
import com.genexus.CommonUtil;
import java.util.*;

import org.apache.commons.lang.StringUtils;

import java.math.BigDecimal;


Expand Down Expand Up @@ -194,7 +192,7 @@ public byte xmlEndElement()
prefix = "";

try {
if (StringUtils.isNotEmpty(prefix))
if (CommonUtil.isNotEmpty(prefix))
out.write("</" + prefix + ":" + node.name + ">\n");
else
out.write("</" + node.name + ">\n");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package com.genexus.sd.store.validation;

//import org.apache.commons.lang.NotImplementedException;

import java.util.List;

import org.apache.commons.lang.NotImplementedException;

import com.genexus.GXBaseCollection;
import com.genexus.sd.store.validation.model.PurchaseResult;
import com.genexus.sd.store.validation.model.PurchasesInformation;
Expand Down Expand Up @@ -128,7 +124,7 @@ private IStoreManager getManager(GXXMLSerializable gxStoreConfig, int platform)
((GooglePlayStoreManager)mgr).setCertificatePath(GetConfigValue("googleCertificate", storeConfig));
break;
default:
throw new NotImplementedException("StoreManager Platform not implemented");
throw new UnsupportedOperationException("StoreManager Platform not implemented");
}
return mgr;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

import javax.net.ssl.HttpsURLConnection;

import org.apache.commons.lang.NotImplementedException;

import com.genexus.cryptography.GXHashing;
import com.genexus.sd.store.validation.model.*;
import com.genexus.sd.store.validation.model.exceptions.*;
Expand Down Expand Up @@ -112,7 +110,7 @@ private StorePurchase validatePurchase(String purchaseToken, PurchaseResult purc
case 21005:
throw new StoreResponsePurchaseException("The receipt server is not currently available.");
case 21006:
throw new NotImplementedException();
throw new UnsupportedOperationException();
case 21007:
dataCache.remove(key);
throw new StoreResponseEnvironmentException();
Expand All @@ -121,7 +119,7 @@ private StorePurchase validatePurchase(String purchaseToken, PurchaseResult purc
case 0:
break;
default:
throw new NotImplementedException();
throw new UnsupportedOperationException();
}
boolean found = false;
if (jResponse.has("receipt"))
Expand Down
3 changes: 1 addition & 2 deletions gxmail/src/main/java/com/genexus/internet/SMTPSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import java.util.TimeZone;

import org.apache.commons.codec.binary.Base64OutputStream;
import org.apache.commons.lang.StringUtils;

import com.genexus.CommonUtil;
import com.genexus.common.interfaces.SpecificImplementation;
Expand Down Expand Up @@ -263,7 +262,7 @@ private void sendAllRecipients(MailRecipientCollection msgList, String cmd) thro
addresses.add(recipient.getRecipientString(addressFormat));

}
println(cmd + ": " + StringUtils.join(addresses, ','));
println(cmd + ": " + CommonUtil.join(addresses, ","));
}
}

Expand Down
2 changes: 1 addition & 1 deletion java/src/main/java/com/genexus/PrivateUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ public static String checkFileNameLength(String baseDir, String fileName, String
int pathLength;
int fileNameLength = fileName.length();
int extensionLength = extension.length();
if (org.apache.commons.lang.SystemUtils.IS_OS_WINDOWS)
if (isWindowsPlatform())
{
pathLength = baseDir.length() + fileNameLength + extensionLength;
if (pathLength > 260)
Expand Down
4 changes: 2 additions & 2 deletions java/src/main/java/com/genexus/cache/redis/RedisClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import java.util.ArrayList;
import java.util.List;

import com.genexus.CommonUtil;
import com.google.common.collect.Lists;
import org.apache.commons.lang.StringUtils;

import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.fasterxml.jackson.annotation.PropertyAccessor;
Expand Down Expand Up @@ -151,7 +151,7 @@ private <T> T get(String key, Class<T> type) {
try {
jedis = pool.getResource();
String json = jedis.get(key);
if (StringUtils.isNotEmpty(json))
if (CommonUtil.isNotEmpty(json))
{
return objMapper.readValue(json, type);
}
Expand Down
7 changes: 3 additions & 4 deletions java/src/main/java/com/genexus/cryptography/GXHashing.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
import java.security.NoSuchAlgorithmException;
import java.security.SignatureException;

import org.apache.commons.lang.StringUtils;

import com.genexus.CommonUtil;
import com.genexus.cryptography.hashing.IGXHashing;
import com.genexus.cryptography.hashing.KeyedHashProvider;
import com.genexus.cryptography.hashing.MessageDigestProvider;
Expand Down Expand Up @@ -45,13 +44,13 @@ public String compute(String text, String key) {
initialize();
if (!anyError()) {
boolean keyHashAlgorithm = _hash instanceof KeyedHashProvider;
if (keyHashAlgorithm && StringUtils.isBlank(key))
if (keyHashAlgorithm && CommonUtil.isBlank(key))
{
setError(4);
}
else
{
if (!keyHashAlgorithm && !StringUtils.isBlank(key))
if (!keyHashAlgorithm && !CommonUtil.isBlank(key))
{
setError(3);
}
Expand Down
1 change: 0 additions & 1 deletion java/src/main/java/com/genexus/internet/HttpContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import json.org.json.JSONArray;
import json.org.json.JSONException;
import json.org.json.JSONObject;
import org.apache.commons.lang.StringEscapeUtils;

public abstract class HttpContext
extends HttpAjaxContext implements IHttpContext
Expand Down
13 changes: 6 additions & 7 deletions java/src/main/java/com/genexus/security/web/SecureToken.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package com.genexus.security.web;
import org.apache.commons.lang.NotImplementedException;

import com.genexus.internet.IGxJSONAble;

Expand All @@ -8,30 +7,30 @@
public abstract class SecureToken implements IGxJSONAble{
public void tojson()
{
throw new NotImplementedException();
throw new UnsupportedOperationException();
}
public void AddObjectProperty(String name, Object prop)
{
throw new NotImplementedException();
throw new UnsupportedOperationException();
}

public Object GetJSONObject()
{
throw new NotImplementedException();
throw new UnsupportedOperationException();
}

public Object GetJSONObject(boolean includeState)
{
throw new NotImplementedException();
throw new UnsupportedOperationException();
}

public void FromJSONObject(IJsonFormattable obj)
{
throw new NotImplementedException();
throw new UnsupportedOperationException();
}

public String ToJavascriptSource()
{
throw new NotImplementedException();
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import java.util.Map;

import org.apache.commons.lang.NotImplementedException;
import org.apache.commons.lang.StringUtils;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.genexus.CommonUtil;
import com.genexus.diagnostics.core.ILogger;
import com.genexus.diagnostics.core.LogManager;
import com.genexus.security.web.jose.jwt.JWTSigner;
Expand Down Expand Up @@ -44,7 +42,7 @@ public static String sign(SecureToken token, SecurityMode mode, String secretKey
break;
case SignEncrypt:
case None:
throw new NotImplementedException();
throw new UnsupportedOperationException();
}
}
catch (Exception e1) {
Expand All @@ -57,7 +55,7 @@ public static boolean verify(String jwtToken, SecureToken outToken, String secre
{
JWTVerifier verifier = new JWTVerifier(secretKey);
boolean ok = false;
if (!StringUtils.isBlank(jwtToken))
if (!CommonUtil.isBlank(jwtToken))
{
try {
Map<String,Object> mapObj = verifier.verify(jwtToken);
Expand Down
11 changes: 6 additions & 5 deletions java/src/main/java/com/genexus/security/web/WebSecureToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import java.util.Date;

import org.apache.commons.lang.StringUtils;
import com.genexus.CommonUtil;
import com.genexus.GXutil;

import json.org.json.IJsonFormattable;
import json.org.json.JSONException;
Expand All @@ -23,11 +24,11 @@ public class WebSecureToken extends SecureToken {
private JSONObject _jObj = new JSONObject();

public WebSecureToken(){
_expiration = org.apache.commons.lang.time.DateUtils.addDays(new Date(), TOKEN_DAYS_EXPIRATION);
_expiration = GXutil.dadd(new Date(), TOKEN_DAYS_EXPIRATION);
}

public WebSecureToken(String pgmName, String issuer, String value) {
_expiration = org.apache.commons.lang.time.DateUtils.addDays(new Date(), TOKEN_DAYS_EXPIRATION);
_expiration = GXutil.dadd(new Date(), TOKEN_DAYS_EXPIRATION);
_pgmName = pgmName;
_value = value;
_issuer = issuer;
Expand Down Expand Up @@ -69,7 +70,7 @@ public void tojson()
public void AddObjectProperty(String name, Object prop)
{
String ptyValue = ((String)prop);
if (!StringUtils.isBlank(name) && !StringUtils.isBlank(ptyValue))
if (!CommonUtil.isBlank(name) && !CommonUtil.isBlank(ptyValue))
{
try {
_jObj.put(name, ptyValue);
Expand Down Expand Up @@ -97,7 +98,7 @@ public void FromJSONObject(IJsonFormattable obj)
this._value = getJsonPtyValueString(jObj, WebSecureToken.JSON_VALUE_NAME);
this._pgmName = getJsonPtyValueString(jObj, WebSecureToken.JSON_PGMNAME_NAME);
String expLong = getJsonPtyValueString(jObj, WebSecureToken.JSON_EXPIRATION_NAME);
if (!StringUtils.isBlank(expLong)){
if (!CommonUtil.isBlank(expLong)){
this._expiration.setTime(Long.parseLong(expLong));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import java.util.Date;

import com.genexus.CommonUtil;
import com.genexus.ModelContext;
import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.Logger;

import com.genexus.security.web.SecureTokenHelper.SecurityMode;
Expand Down Expand Up @@ -44,7 +44,7 @@ public static boolean verify(String pgmName, String issuer, String value, String
WebSecureToken token = new WebSecureToken();
if(!SecureTokenHelper.verify(jwtToken, token, getSecretKey()))
return false;
boolean ret = !StringUtils.isBlank(pgmName) && token.get_pgmName().equals(pgmName) && issuer.equals(token.get_issuer()) &&
boolean ret = !CommonUtil.isBlank(pgmName) && token.get_pgmName().equals(pgmName) && issuer.equals(token.get_issuer()) &&
StripInvalidChars(value).equals(StripInvalidChars(token.get_value())) && new Date().compareTo(token.get_expiration()) < 0;
if (!ret && log.isDebugEnabled()) {
String lsep = System.getProperty("line.separator");
Expand Down
Loading

0 comments on commit ddcf060

Please sign in to comment.