diff --git a/android/src/main/java/com/genexus/util/GxJsonReader.java b/android/src/main/java/com/genexus/util/GxJsonReader.java index ba1ba2dd2..5e48f26be 100644 --- a/android/src/main/java/com/genexus/util/GxJsonReader.java +++ b/android/src/main/java/com/genexus/util/GxJsonReader.java @@ -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; @@ -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 } } diff --git a/common/pom.xml b/common/pom.xml index 7ba753435..124948dbf 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -24,11 +24,6 @@ commons-codec 1.4 - - commons-lang - commons-lang - 2.4 - commons-io commons-io diff --git a/common/src/main/java/com/genexus/BaseProvider.java b/common/src/main/java/com/genexus/BaseProvider.java index d54b5ef92..2755542e7 100644 --- a/common/src/main/java/com/genexus/BaseProvider.java +++ b/common/src/main/java/com/genexus/BaseProvider.java @@ -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; @@ -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; diff --git a/common/src/main/java/com/genexus/CommonUtil.java b/common/src/main/java/com/genexus/CommonUtil.java index 3447df744..697bb2862 100644 --- a/common/src/main/java/com/genexus/CommonUtil.java +++ b/common/src/main/java/com/genexus/CommonUtil.java @@ -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; @@ -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)); @@ -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 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(); + } } diff --git a/common/src/main/java/com/genexus/util/ExpressionEvaluator.java b/common/src/main/java/com/genexus/util/ExpressionEvaluator.java index ca773d9ea..44738be9b 100644 --- a/common/src/main/java/com/genexus/util/ExpressionEvaluator.java +++ b/common/src/main/java/com/genexus/util/ExpressionEvaluator.java @@ -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; @@ -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 diff --git a/common/src/main/java/com/genexus/xml/XMLWriter.java b/common/src/main/java/com/genexus/xml/XMLWriter.java index b4c8a0cf4..f4db922d9 100644 --- a/common/src/main/java/com/genexus/xml/XMLWriter.java +++ b/common/src/main/java/com/genexus/xml/XMLWriter.java @@ -8,8 +8,6 @@ import com.genexus.CommonUtil; import java.util.*; -import org.apache.commons.lang.StringUtils; - import java.math.BigDecimal; @@ -194,7 +192,7 @@ public byte xmlEndElement() prefix = ""; try { - if (StringUtils.isNotEmpty(prefix)) + if (CommonUtil.isNotEmpty(prefix)) out.write("\n"); else out.write("\n"); diff --git a/gxandroidpublisher/src/main/java/com/genexus/sd/store/validation/StoreManager.java b/gxandroidpublisher/src/main/java/com/genexus/sd/store/validation/StoreManager.java index 22a202e09..c81d27963 100644 --- a/gxandroidpublisher/src/main/java/com/genexus/sd/store/validation/StoreManager.java +++ b/gxandroidpublisher/src/main/java/com/genexus/sd/store/validation/StoreManager.java @@ -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; @@ -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; } diff --git a/gxandroidpublisher/src/main/java/com/genexus/sd/store/validation/platforms/AppleStoreStoreManager.java b/gxandroidpublisher/src/main/java/com/genexus/sd/store/validation/platforms/AppleStoreStoreManager.java index 67dfc69c8..0dc41c77f 100644 --- a/gxandroidpublisher/src/main/java/com/genexus/sd/store/validation/platforms/AppleStoreStoreManager.java +++ b/gxandroidpublisher/src/main/java/com/genexus/sd/store/validation/platforms/AppleStoreStoreManager.java @@ -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.*; @@ -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(); @@ -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")) diff --git a/gxmail/src/main/java/com/genexus/internet/SMTPSession.java b/gxmail/src/main/java/com/genexus/internet/SMTPSession.java index b5fd3c6a7..b4852b6a7 100644 --- a/gxmail/src/main/java/com/genexus/internet/SMTPSession.java +++ b/gxmail/src/main/java/com/genexus/internet/SMTPSession.java @@ -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; @@ -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, ",")); } } diff --git a/java/src/main/java/com/genexus/PrivateUtilities.java b/java/src/main/java/com/genexus/PrivateUtilities.java index 9db3a056c..e5016d248 100644 --- a/java/src/main/java/com/genexus/PrivateUtilities.java +++ b/java/src/main/java/com/genexus/PrivateUtilities.java @@ -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) diff --git a/java/src/main/java/com/genexus/cache/redis/RedisClient.java b/java/src/main/java/com/genexus/cache/redis/RedisClient.java index 8fce349c3..94e1e643e 100644 --- a/java/src/main/java/com/genexus/cache/redis/RedisClient.java +++ b/java/src/main/java/com/genexus/cache/redis/RedisClient.java @@ -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; @@ -151,7 +151,7 @@ private T get(String key, Class type) { try { jedis = pool.getResource(); String json = jedis.get(key); - if (StringUtils.isNotEmpty(json)) + if (CommonUtil.isNotEmpty(json)) { return objMapper.readValue(json, type); } diff --git a/java/src/main/java/com/genexus/cryptography/GXHashing.java b/java/src/main/java/com/genexus/cryptography/GXHashing.java index 6e7b9da87..c30c3d68a 100644 --- a/java/src/main/java/com/genexus/cryptography/GXHashing.java +++ b/java/src/main/java/com/genexus/cryptography/GXHashing.java @@ -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; @@ -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); } diff --git a/java/src/main/java/com/genexus/internet/HttpContext.java b/java/src/main/java/com/genexus/internet/HttpContext.java index 50b135b44..51b240a2b 100644 --- a/java/src/main/java/com/genexus/internet/HttpContext.java +++ b/java/src/main/java/com/genexus/internet/HttpContext.java @@ -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 diff --git a/java/src/main/java/com/genexus/security/web/SecureToken.java b/java/src/main/java/com/genexus/security/web/SecureToken.java index eb94d9ad0..8e58fb314 100644 --- a/java/src/main/java/com/genexus/security/web/SecureToken.java +++ b/java/src/main/java/com/genexus/security/web/SecureToken.java @@ -1,5 +1,4 @@ package com.genexus.security.web; -import org.apache.commons.lang.NotImplementedException; import com.genexus.internet.IGxJSONAble; @@ -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(); } } diff --git a/java/src/main/java/com/genexus/security/web/SecureTokenHelper.java b/java/src/main/java/com/genexus/security/web/SecureTokenHelper.java index 74992d9a6..7c4cbf87d 100644 --- a/java/src/main/java/com/genexus/security/web/SecureTokenHelper.java +++ b/java/src/main/java/com/genexus/security/web/SecureTokenHelper.java @@ -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; @@ -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) { @@ -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 mapObj = verifier.verify(jwtToken); diff --git a/java/src/main/java/com/genexus/security/web/WebSecureToken.java b/java/src/main/java/com/genexus/security/web/WebSecureToken.java index cece09808..984c80a59 100644 --- a/java/src/main/java/com/genexus/security/web/WebSecureToken.java +++ b/java/src/main/java/com/genexus/security/web/WebSecureToken.java @@ -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; @@ -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; @@ -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); @@ -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)); } } diff --git a/java/src/main/java/com/genexus/security/web/WebSecurityHelper.java b/java/src/main/java/com/genexus/security/web/WebSecurityHelper.java index 83342d51f..534369721 100644 --- a/java/src/main/java/com/genexus/security/web/WebSecurityHelper.java +++ b/java/src/main/java/com/genexus/security/web/WebSecurityHelper.java @@ -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; @@ -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"); diff --git a/java/src/main/java/com/genexus/security/web/jose/jwt/JWTSigner.java b/java/src/main/java/com/genexus/security/web/jose/jwt/JWTSigner.java index efc362552..9bc96ed4f 100644 --- a/java/src/main/java/com/genexus/security/web/jose/jwt/JWTSigner.java +++ b/java/src/main/java/com/genexus/security/web/jose/jwt/JWTSigner.java @@ -22,6 +22,7 @@ import javax.crypto.Mac; import javax.crypto.spec.SecretKeySpec; +import com.genexus.CommonUtil; import org.apache.commons.codec.binary.Base64; import org.bouncycastle.jce.provider.BouncyCastleProvider; @@ -269,7 +270,7 @@ private static byte[] signRs(final Algorithm algorithm, final String msg, final } private String join(final List input, final String separator) { - return org.apache.commons.lang.StringUtils.join(input.iterator(), separator); + return CommonUtil.join(input, separator); } /** diff --git a/java/src/main/java/com/genexus/webpanels/GXWebObjectBase.java b/java/src/main/java/com/genexus/webpanels/GXWebObjectBase.java index 323c10086..1bdc99b3d 100644 --- a/java/src/main/java/com/genexus/webpanels/GXWebObjectBase.java +++ b/java/src/main/java/com/genexus/webpanels/GXWebObjectBase.java @@ -8,7 +8,6 @@ import com.genexus.configuration.ConfigurationManager; import com.genexus.diagnostics.GXDebugInfo; import com.genexus.diagnostics.GXDebugManager; -import org.apache.commons.lang.StringUtils; import com.genexus.ModelContext; import com.genexus.db.Namespace; @@ -193,7 +192,7 @@ protected void sendAdditionalHeaders() String IECompMode = context.getClientPreferences().getIE_COMPATIBILITY(); if (IECompMode.equals("EmulateIE7") && !httpContext.getBrowserVersion().startsWith("8") ) return; - if (StringUtils.isNotEmpty(IECompMode)) + if (CommonUtil.isNotEmpty(IECompMode)) httpContext.getResponse().addHeader("X-UA-Compatible", "IE=" + IECompMode); } } @@ -488,7 +487,7 @@ private String serialize(long Value, String Pic) private String serialize(Object Value, String Pic) { - if (!StringUtils.isBlank(Pic)) { + if (!CommonUtil.isBlank(Pic)) { if (Value instanceof Byte) { return serialize(localUtil.format(((Byte)Value).intValue(), Pic)); @@ -642,7 +641,7 @@ protected boolean validateObjectAccess(String cmpCtx) { if (this.httpContext.useSecurityTokenValidation()){ String jwtToken = this.httpContext.getHeader("X-GXAUTH-TOKEN"); - jwtToken = (StringUtils.isBlank(jwtToken) && this.httpContext.isMultipartContent())? + jwtToken = (CommonUtil.isBlank(jwtToken) && this.httpContext.isMultipartContent())? this.httpContext.cgiGet("X-GXAUTH-TOKEN"): jwtToken; diff --git a/java/src/main/java/com/genexus/webpanels/HttpContextWeb.java b/java/src/main/java/com/genexus/webpanels/HttpContextWeb.java index 727f2cb05..0032d0c38 100644 --- a/java/src/main/java/com/genexus/webpanels/HttpContextWeb.java +++ b/java/src/main/java/com/genexus/webpanels/HttpContextWeb.java @@ -29,7 +29,6 @@ import org.apache.commons.fileupload.FileItemIterator; import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.apache.commons.io.FilenameUtils; -import org.apache.commons.lang.StringUtils; import org.apache.logging.log4j.Logger; import com.genexus.internet.GXNavigationHelper; @@ -493,7 +492,7 @@ public String getReferer() { } try { URL url = new URL(referer); - String query = (StringUtils.isNotEmpty(url.getQuery())) ? "?" + url.getQuery() : ""; + String query = (CommonUtil.isNotEmpty(url.getQuery())) ? "?" + url.getQuery() : ""; referer = url.getPath() + query; } catch (Exception e) { diff --git a/javapns/src/main/java/javapns/devices/implementations/basic/BasicDeviceFactory.java b/javapns/src/main/java/javapns/devices/implementations/basic/BasicDeviceFactory.java index b8c29e7a1..5de4a197e 100644 --- a/javapns/src/main/java/javapns/devices/implementations/basic/BasicDeviceFactory.java +++ b/javapns/src/main/java/javapns/devices/implementations/basic/BasicDeviceFactory.java @@ -3,11 +3,11 @@ import java.sql.*; import java.util.*; +import com.genexus.CommonUtil; import javapns.devices.*; import javapns.devices.exceptions.*; import javapns.notification.*; -import org.apache.commons.lang.*; import com.genexus.diagnostics.core.*; /** @@ -56,7 +56,7 @@ public Device addDevice(String id, String token) throws DuplicateDeviceException throw new NullDeviceTokenException(); } else { if (!this.devices.containsKey(id)) { - token = StringUtils.deleteWhitespace(token); + token = CommonUtil.deleteWhitespace(token); BasicDevice device = new BasicDevice(id, token, new Timestamp(Calendar.getInstance().getTime().getTime())); this.devices.put(id, device); return device; @@ -66,7 +66,6 @@ public Device addDevice(String id, String token) throws DuplicateDeviceException } } - /** * Get a device according to his id * @param id The device id