diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/AliasKeyManager.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/AliasKeyManager.java
index 9660244ce8..05bdabe2dd 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/AliasKeyManager.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/AliasKeyManager.java
@@ -49,7 +49,9 @@ public class AliasKeyManager implements X509KeyManager {
if (aliases != null && aliases.length > 0) {
for (String alias: aliases) {
if (this.alias.equals(alias)) {
- if (Debug.verboseOn()) Debug.logVerbose("chooseClientAlias for keyType [" + keyType + "] got alias " + this.alias, module);
+ if (Debug.verboseOn()) {
+ Debug.logVerbose("chooseClientAlias for keyType [" + keyType + "] got alias " + this.alias, module);
+ }
return this.alias;
}
}
@@ -70,7 +72,9 @@ public class AliasKeyManager implements X509KeyManager {
public X509Certificate[] getCertificateChain(String alias) {
X509Certificate[] certArray = keyManager.getCertificateChain(alias);
- if (Debug.verboseOn()) Debug.logVerbose("getCertificateChain for alias [" + alias + "] got " + certArray.length + " results", module);
+ if (Debug.verboseOn()) {
+ Debug.logVerbose("getCertificateChain for alias [" + alias + "] got " + certArray.length + " results", module);
+ }
return certArray;
}
@@ -80,7 +84,9 @@ public class AliasKeyManager implements X509KeyManager {
public PrivateKey getPrivateKey(String alias) {
PrivateKey pk = keyManager.getPrivateKey(alias);
- if (Debug.verboseOn()) Debug.logVerbose("getPrivateKey for alias [" + alias + "] got " + (pk == null ? "[Not Found!]" : "[alg:" + pk.getAlgorithm() + ";format:" + pk.getFormat() + "]"), module);
+ if (Debug.verboseOn()) {
+ Debug.logVerbose("getPrivateKey for alias [" + alias + "] got " + (pk == null ? "[Not Found!]" : "[alg:" + pk.getAlgorithm() + ";format:" + pk.getFormat() + "]"), module);
+ }
return pk;
}
diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/Assert.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/Assert.java
index 308626d634..1cea0d8293 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/Assert.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/Assert.java
@@ -5,9 +5,9 @@
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -25,7 +25,7 @@ import org.apache.ofbiz.base.lang.ThreadSafe;
/** Basic assertions. The static methods in this class provide a convenient way
* to test method arguments. All of the methods in this class throw
* IllegalArgumentException if the method arguments are invalid.
- *
+ *
*/
@ThreadSafe
public class Assert {
@@ -33,7 +33,7 @@ public class Assert {
/**
* Tests if an argument is not null and can be cast to a specified class.
*
Assert.isAssignableTo("foo", foo, Foo.class);
- *
+ *
* @param argumentName
* @param argumentObject
* @param targetClass
@@ -49,7 +49,7 @@ public class Assert {
/**
* Tests if an argument is not null and is an instance of a specified class.
*
Assert.isInstanceOf("foo", foo, Foo.class);
- *
+ *
* @param argumentName
* @param argumentObject
* @param targetClass
@@ -65,7 +65,7 @@ public class Assert {
/**
* Tests if an argument is not null and is an instance of one of the specified classes.
*
- *
+ *
* @param argumentName
* @param argumentObject
* @param targetClasses
@@ -92,7 +92,7 @@ public class Assert {
/**
* Tests if an argument is not null and is not an instance of a specified class.
*
Assert.isNotInstanceOf("foo", foo, Foo.class);
- *
+ *
* @param argumentName
* @param argumentObject
* @param targetClass
@@ -108,7 +108,7 @@ public class Assert {
/**
* Tests if an argument is not null and is not an instance of one of the specified classes.
*
- *
+ *
* @param argumentName
* @param argumentObject
* @param targetClasses
@@ -127,7 +127,7 @@ public class Assert {
/**
* Tests if an argument is not null and is not empty.
*
Assert.notEmpty("foo", foo);
- *
+ *
* @param argumentName
* @param argumentObject
* @throws IllegalArgumentException
@@ -142,7 +142,7 @@ public class Assert {
/**
* Tests if an argument is not null and is not empty.
*
Assert.notEmpty("foo", foo);
- *
+ *
* @param argumentName
* @param argumentObject
* @throws IllegalArgumentException
@@ -157,7 +157,7 @@ public class Assert {
/**
* Tests if an argument is not null and is not empty.
*
Assert.notEmpty("foo", foo);
- *
+ *
* @param argumentName
* @param argumentObject
* @throws IllegalArgumentException
@@ -172,7 +172,7 @@ public class Assert {
/**
* Tests if an argument is not null and is not empty.
*
Assert.notEmpty("foo", foo);
- *
+ *
* @param argumentName
* @param argumentObject
* @throws IllegalArgumentException
@@ -187,7 +187,7 @@ public class Assert {
/**
* Tests a list of arguments for null.
*
Assert.notNull("foo", foo, "bar", bar, ...);
- *
+ *
* @param arguments
* @throws IllegalArgumentException
*/
@@ -200,7 +200,7 @@ public class Assert {
/**
* Tests an argument for null.
*
Assert.notNull("foo", foo);
- *
+ *
* @param argumentName
* @param objectToTest
* @throws IllegalArgumentException
diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/Base64.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/Base64.java
index 777cca1b97..da944a6b97 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/Base64.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/Base64.java
@@ -150,7 +150,9 @@ public class Base64 {
* @return the decoded str.
*/
public final static String base64Decode(String str) {
- if (str == null) return null;
+ if (str == null) {
+ return null;
+ }
return new String(base64Decode(str.getBytes(UtilIO.getUtf8())));
}
@@ -182,8 +184,9 @@ public class Base64 {
if (sidx < data.length - 1) {
dest[didx++] = base64EncMap[(data[sidx + 1] >>> 4) & 017 | (data[sidx] << 4) & 077];
dest[didx++] = base64EncMap[(data[sidx + 1] << 2) & 077];
- } else
+ } else {
dest[didx++] = base64EncMap[(data[sidx] << 4) & 077];
+ }
}
// add padding
diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/Debug.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/Debug.java
index 7bc01dd66a..cb04a9920e 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/Debug.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/Debug.java
@@ -49,7 +49,7 @@ public final class Debug {
private static final String[] levelProps = {"", "print.verbose", "print.timing", "print.info", "print.important", "print.warning", "print.error", "print.fatal"};
private static final Level[] levelObjs = {Level.FATAL, Level.DEBUG, Level.TRACE, Level.INFO, Level.INFO, Level.WARN, Level.ERROR, Level.FATAL};
- private static final Map levelStringMap = new HashMap();
+ private static final Map levelStringMap = new HashMap<>();
private static final boolean levelOnCache[] = new boolean[8]; // this field is not thread safe
@@ -79,14 +79,15 @@ public final class Debug {
public static Logger getLogger(String module) {
if (UtilValidate.isNotEmpty(module)) {
return LogManager.getLogger(module);
- } else {
- return root;
}
+ return root;
}
/** Gets an Integer representing the level number from a String representing the level name; will return null if not found */
public static Integer getLevelFromString(String levelName) {
- if (levelName == null) return null;
+ if (levelName == null) {
+ return null;
+ }
return levelStringMap.get(levelName.toLowerCase(Locale.getDefault()));
}
diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/FileUtil.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/FileUtil.java
index 45f9426277..3193bdb8c9 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/FileUtil.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/FileUtil.java
@@ -25,8 +25,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.FileWriter;
import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStreamReader;
@@ -55,8 +53,8 @@ public final class FileUtil {
private static class SearchTextFilesFilter implements FilenameFilter {
String fileExtension;
- Set stringsToFindInFile = new HashSet();
- Set stringsToFindInPath = new HashSet();
+ Set stringsToFindInFile = new HashSet<>();
+ Set stringsToFindInPath = new HashSet<>();
public SearchTextFilesFilter(String fileExtension, Set stringsToFindInPath, Set stringsToFindInFile) {
this.fileExtension = fileExtension;
@@ -94,9 +92,6 @@ public final class FileUtil {
StringBuffer xmlFileBuffer = null;
try {
xmlFileBuffer = FileUtil.readTextFile(file, true);
- } catch (FileNotFoundException e) {
- Debug.logWarning("Error reading xml file [" + file + "] for file search: " + e.toString(), module);
- return false;
} catch (IOException e) {
Debug.logWarning("Error reading xml file [" + file + "] for file search: " + e.toString(), module);
return false;
@@ -149,7 +144,7 @@ public final class FileUtil {
writeString(null, fileName, s);
}
- public static void writeString(String path, String name, String s) throws IOException {
+ public static void writeString(String path, String name, String s) {
try (
Writer out = getBufferedWriter(path, name);
@@ -297,8 +292,8 @@ public final class FileUtil {
basePath = System.getProperty("ofbiz.home");
}
- Set stringsToFindInPath = new HashSet();
- Set stringsToFindInFile = new HashSet();
+ Set stringsToFindInPath = new HashSet<>();
+ Set stringsToFindInFile = new HashSet<>();
if (partialPath != null) {
stringsToFindInPath.add(partialPath);
@@ -307,7 +302,7 @@ public final class FileUtil {
stringsToFindInFile.add(stringToFind);
}
- List fileList = new LinkedList();
+ List fileList = new LinkedList<>();
FileUtil.searchFiles(fileList, new File(basePath), new SearchTextFilesFilter(fileExt, stringsToFindInPath, stringsToFindInFile), true);
return fileList;
@@ -318,14 +313,20 @@ public final class FileUtil {
basePath = System.getProperty("ofbiz.home");
}
- Set stringsToFindInPath = new HashSet();
- Set stringsToFindInFile = new HashSet();
+ Set stringsToFindInPath = new HashSet<>();
+ Set stringsToFindInFile = new HashSet<>();
- if (partialPath != null) stringsToFindInPath.add(partialPath);
- if (rootElementName != null) stringsToFindInFile.add("<" + rootElementName + " ");
- if (xsdOrDtdName != null) stringsToFindInFile.add(xsdOrDtdName);
+ if (partialPath != null) {
+ stringsToFindInPath.add(partialPath);
+ }
+ if (rootElementName != null) {
+ stringsToFindInFile.add("<" + rootElementName + " ");
+ }
+ if (xsdOrDtdName != null) {
+ stringsToFindInFile.add(xsdOrDtdName);
+ }
- List fileList = new LinkedList();
+ List fileList = new LinkedList<>();
FileUtil.searchFiles(fileList, new File(basePath), new SearchTextFilesFilter("xml", stringsToFindInPath, stringsToFindInFile), true);
return fileList;
}
@@ -348,9 +349,14 @@ public final class FileUtil {
int count = 0;
while((numCharsRead = reader.read(buffer)) > 0) {
for (int c = 0; c < numCharsRead; ++c) {
- if (buffer[c] == searchString.charAt(count)) count++;
- else count = 0;
- if (count == searchString.length()) return true;
+ if (buffer[c] == searchString.charAt(count)) {
+ count++;
+ } else {
+ count = 0;
+ }
+ if (count == searchString.length()) {
+ return true;
+ }
}
}
return false;
@@ -377,9 +383,8 @@ public final class FileUtil {
) {
return containsString(in, searchString);
}
- } else {
- return false;
}
+ return false;
}
/**
@@ -396,5 +401,4 @@ public final class FileUtil {
File f = new File(fileName);
return f.isFile();
}
-
}
diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/GeneralException.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/GeneralException.java
index 7d94b4acbf..dd575da26c 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/GeneralException.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/GeneralException.java
@@ -34,9 +34,15 @@ public class GeneralException extends Exception {
}
public static T checkException(String message, Throwable t) throws GeneralException {
- if (t instanceof Error) throw (Error) t;
- if (t instanceof RuntimeException) throw (RuntimeException) t;
- if (t instanceof GeneralException) throw (GeneralException) t;
+ if (t instanceof Error) {
+ throw (Error) t;
+ }
+ if (t instanceof RuntimeException) {
+ throw (RuntimeException) t;
+ }
+ if (t instanceof GeneralException) {
+ throw (GeneralException) t;
+ }
throw (GeneralException) new GeneralException(message).initCause(t);
}
@@ -117,12 +123,10 @@ public class GeneralException extends Exception {
if (nested != null) {
if (super.getMessage() == null) {
return nested.getMessage();
- } else {
- return super.getMessage() + " (" + nested.getMessage() + ")";
}
- } else {
- return super.getMessage();
+ return super.getMessage() + " (" + nested.getMessage() + ")";
}
+ return super.getMessage();
}
public List getMessageList() {
diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/GeneralRuntimeException.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/GeneralRuntimeException.java
index 7cc862737c..01cd20406b 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/GeneralRuntimeException.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/GeneralRuntimeException.java
@@ -66,10 +66,10 @@ public class GeneralRuntimeException extends RuntimeException {
/** Returns the detail message, including the message from the nested exception if there is one. */
@Override
public String getMessage() {
- if (nested != null)
+ if (nested != null) {
return super.getMessage() + " (" + nested.getMessage() + ")";
- else
- return super.getMessage();
+ }
+ return super.getMessage();
}
/** Returns the detail message, NOT including the message from the nested exception. */
@@ -86,20 +86,26 @@ public class GeneralRuntimeException extends RuntimeException {
@Override
public void printStackTrace() {
super.printStackTrace();
- if (nested != null) nested.printStackTrace();
+ if (nested != null) {
+ nested.printStackTrace();
+ }
}
/** Prints the composite message and the embedded stack trace to the specified stream ps. */
@Override
public void printStackTrace(PrintStream ps) {
super.printStackTrace(ps);
- if (nested != null) nested.printStackTrace(ps);
+ if (nested != null) {
+ nested.printStackTrace(ps);
+ }
}
/** Prints the composite message and the embedded stack trace to the specified print writer pw. */
@Override
public void printStackTrace(PrintWriter pw) {
super.printStackTrace(pw);
- if (nested != null) nested.printStackTrace(pw);
+ if (nested != null) {
+ nested.printStackTrace(pw);
+ }
}
}
diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/GroovyUtil.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/GroovyUtil.java
index 108d00060e..672a684dec 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/GroovyUtil.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/GroovyUtil.java
@@ -64,7 +64,7 @@ public class GroovyUtil {
*/
try {
GroovyUtil.runScriptAtLocation("component://base/config/GroovyInit.groovy", null, null);
- } catch(Exception e) {
+ } catch (Exception e) {
Debug.logWarning("The following error occurred during the initialization of Groovy: " + e.getMessage(), module);
}
}
@@ -114,19 +114,22 @@ public class GroovyUtil {
* back to the caller. Any variables that are created in the script
* are lost when the script ends unless they are copied to the
* "context" Map.
- *
+ *
* @param context A Map containing initial variables
* @return A Binding instance
*/
public static Binding getBinding(Map context, String expression) {
- Map vars = new HashMap();
+ Map vars = new HashMap<>();
if (context != null) {
vars.putAll(context);
if (UtilValidate.isNotEmpty(expression)) {
//analyse expression to find variables by split non alpha, ignoring "_" to allow my_variable usage
String [] variables = expression.split("[\\P{Alpha}&&[^_]]+");
- for (String variable: variables)
- if(!vars.containsKey(variable)) vars.put(variable, null);
+ for (String variable: variables) {
+ if(!vars.containsKey(variable)) {
+ vars.put(variable, null);
+ }
+ }
}
vars.put("context", context);
if (vars.get(ScriptUtil.SCRIPT_HELPER_KEY) == null) {
diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpClient.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpClient.java
index 354269b4a6..7ad0154eea 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpClient.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpClient.java
@@ -144,8 +144,9 @@ public class HttpClient {
/** Set an individual parameter for this request. */
public void setParameter(String name, String value) {
- if (parameters == null)
- parameters = new HashMap();
+ if (parameters == null) {
+ parameters = new HashMap<>();
+ }
parameters.put(name, value);
}
@@ -156,8 +157,9 @@ public class HttpClient {
/** Set an individual header for this request. */
public void setHeader(String name, String value) {
- if (headers == null)
- headers = new HashMap();
+ if (headers == null) {
+ headers = new HashMap<>();
+ }
headers.put(name, value);
}
@@ -185,12 +187,12 @@ public class HttpClient {
public String getContentType() {
return this.contentType;
}
-
+
/** Sets the scream charset */
public void setStreamCharset(String streamCharset) {
this.streamCharset = streamCharset;
}
-
+
/** Returns the stream charset */
public String getStreamCharset() {
return this.streamCharset;
@@ -340,13 +342,15 @@ public class HttpClient {
public String sendHttpRequest(String method) throws HttpClientException {
InputStream in = sendHttpRequestStream(method);
- if (in == null) return null;
+ if (in == null) {
+ return null;
+ }
StringBuilder buf = new StringBuilder();
try {
if (Debug.verboseOn() || debug) {
try {
- Debug.logInfo("ContentEncoding: " + con.getContentEncoding() + "; ContentType: " +
+ Debug.logVerbose("ContentEncoding: " + con.getContentEncoding() + "; ContentType: " +
con.getContentType() + " or: " + URLConnection.guessContentTypeFromStream(in), module);
} catch (IOException ioe) {
Debug.logWarning(ioe, "Caught exception printing content debugging information", module);
@@ -359,11 +363,15 @@ public class HttpClient {
try {
contentType = URLConnection.guessContentTypeFromStream(in);
} catch (IOException ioe) {
- Debug.logWarning(ioe, "Problems guessing content type from steam", module);
+ if (Debug.warningOn()) {
+ Debug.logWarning(ioe, "Problems guessing content type from stream", module);
+ }
}
}
- if (Debug.verboseOn() || debug) Debug.logVerbose("Content-Type: " + contentType, module);
+ if (Debug.verboseOn() || debug) {
+ Debug.logVerbose("Content-Type: " + contentType, module);
+ }
if (contentType != null) {
contentType = contentType.toUpperCase(Locale.getDefault());
@@ -375,8 +383,12 @@ public class HttpClient {
charset = contentType.substring(charsetEqualsLoc + 1);
}
- if (charset != null) charset = charset.trim().replaceAll("\"", "");
- if (Debug.verboseOn() || debug) Debug.logVerbose("Getting text from HttpClient with charset: " + charset, module);
+ if (charset != null) {
+ charset = charset.trim().replaceAll("\"", "");
+ }
+ if (Debug.verboseOn() || debug) {
+ Debug.logVerbose("Getting text from HttpClient with charset: " + charset, module);
+ }
}
try (
@@ -384,9 +396,13 @@ public class HttpClient {
: new InputStreamReader(in, charset))) {
String line = "";
- if (Debug.verboseOn() || debug) Debug.logVerbose("---- HttpClient Response Content ----", module);
+ if (Debug.verboseOn() || debug) {
+ Debug.logVerbose("---- HttpClient Response Content ----", module);
+ }
while ((line = post.readLine()) != null) {
- if (Debug.verboseOn() || debug) Debug.logVerbose("[HttpClient] : " + line, module);
+ if (Debug.verboseOn() || debug) {
+ Debug.logVerbose("[HttpClient] : " + line, module);
+ }
buf.append(line);
if (lineFeed) {
buf.append("\n");
@@ -439,11 +455,15 @@ public class HttpClient {
} else {
con = URLConnector.openConnection(requestUrl, timeout, clientCertAlias, hostVerification);
}
- if (Debug.verboseOn() || debug) Debug.logVerbose("Connection opened to : " + requestUrl.toExternalForm(), module);
+ if (Debug.verboseOn() || debug) {
+ Debug.logVerbose("Connection opened to : " + requestUrl.toExternalForm(), module);
+ }
if ((con instanceof HttpURLConnection)) {
((HttpURLConnection) con).setInstanceFollowRedirects(followRedirects);
- if (Debug.verboseOn() || debug) Debug.logVerbose("Connection is of type HttpURLConnection, more specifically: " + con.getClass().getName(), module);
+ if (Debug.verboseOn() || debug) {
+ Debug.logVerbose("Connection is of type HttpURLConnection, more specifically: " + con.getClass().getName(), module);
+ }
}
// set the content type
@@ -469,7 +489,9 @@ public class HttpClient {
if (basicAuthUsername != null) {
String basicAuthString = "Basic " + Base64.base64Encode(basicAuthUsername + ":" + (basicAuthPassword == null ? "" : basicAuthPassword));
con.setRequestProperty("Authorization", basicAuthString);
- if (Debug.verboseOn() || debug) Debug.logVerbose("Header - Authorization: " + basicAuthString, module);
+ if (Debug.verboseOn() || debug) {
+ Debug.logVerbose("Header - Authorization: " + basicAuthString, module);
+ }
}
if (UtilValidate.isNotEmpty(headers)) {
@@ -477,7 +499,9 @@ public class HttpClient {
String headerName = entry.getKey();
String headerValue = entry.getValue();
con.setRequestProperty(headerName, headerValue);
- if (Debug.verboseOn() || debug) Debug.logVerbose("Header - " + headerName + ": " + headerValue, module);
+ if (Debug.verboseOn() || debug) {
+ Debug.logVerbose("Header - " + headerName + ": " + headerValue, module);
+ }
}
}
@@ -485,17 +509,20 @@ public class HttpClient {
try (
OutputStreamWriter out = new OutputStreamWriter(con.getOutputStream(),
this.streamCharset != null ? this.streamCharset : "UTF-8")) {
- if (Debug.verboseOn() || debug)
- if (Debug.verboseOn()) Debug.logVerbose("Opened output stream", module);
+ if (Debug.verboseOn() || debug) {
+ Debug.logVerbose("Opened output stream", module);
+ }
if (arguments != null) {
out.write(arguments);
- if (Debug.verboseOn() || debug)
- if (Debug.verboseOn()) Debug.logVerbose("Wrote arguements (parameters) : " + arguments, module);
+ if (Debug.verboseOn() || debug) {
+ Debug.logVerbose("Wrote arguements (parameters) : " + arguments, module);
+ }
}
- if (Debug.verboseOn() || debug)
- if (Debug.verboseOn()) Debug.logVerbose("Flushed and closed buffer", module);
+ if (Debug.verboseOn() || debug) {
+ Debug.logVerbose("Flushed and closed buffer", module);
+ }
}
}
diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpRequestFileUpload.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpRequestFileUpload.java
index 3d0db7eed9..9af96d06da 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpRequestFileUpload.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/HttpRequestFileUpload.java
@@ -73,14 +73,16 @@ public class HttpRequestFileUpload {
}
public String getFieldValue(String fieldName) {
- if (fields == null || fieldName == null)
+ if (fields == null || fieldName == null) {
return null;
+ }
return fields.get(fieldName);
}
private void setFilename(String s) {
- if (s == null)
+ if (s == null) {
return;
+ }
int pos = s.indexOf("filename=\"");
@@ -90,21 +92,24 @@ public class HttpRequestFileUpload {
// But Linux/Unix and Mac browsers only send the filename
// test if this is from a Windows browser
pos = filepath.lastIndexOf("\\");
- if (pos != -1)
+ if (pos != -1) {
filename = filepath.substring(pos + 1);
- else
+ } else {
filename = filepath;
+ }
}
}
private void setContentType(String s) {
- if (s == null)
+ if (s == null) {
return;
+ }
int pos = s.indexOf(": ");
- if (pos != -1)
+ if (pos != -1) {
contentType = s.substring(pos + 2, s.length());
+ }
}
public void doUpload(HttpServletRequest request) throws IOException {
@@ -127,14 +132,15 @@ public class HttpRequestFileUpload {
i = waitingReadLine(in, line, 0, BUFFER_SIZE, requestLength);
requestLength -= i;
- if (i < 3)
+ if (i < 3) {
return;
+ }
int boundaryLength = i - 2;
String boundary = new String(line, 0, boundaryLength, UtilIO.getUtf8()); // -2 discards the newline character
System.out.println("boundary=[" + boundary + "] length is " + boundaryLength);
- fields = new HashMap();
+ fields = new HashMap<>();
while (requestLength > 0/* i != -1*/) {
String newLine = "";
@@ -145,8 +151,9 @@ public class HttpRequestFileUpload {
if (newLine.startsWith("Content-Disposition: form-data; name=\"")) {
if (newLine.indexOf("filename=\"") != -1) {
setFilename(new String(line, 0, i - 2, UtilIO.getUtf8()));
- if (filename == null)
+ if (filename == null) {
return;
+ }
// this is the file content
i = waitingReadLine(in, line, 0, BUFFER_SIZE, requestLength);
requestLength -= i;
@@ -252,10 +259,11 @@ public class HttpRequestFileUpload {
i = waitingReadLine(in, line, 0, BUFFER_SIZE, requestLength);
requestLength -= i;
if ((i == boundaryLength + 2 || i == boundaryLength + 4) // + 4 is eof
- && (new String(line, 0, i).startsWith(boundary)))
+ && (new String(line, 0, i).startsWith(boundary))) {
fieldValue.append(newLine.substring(0, newLine.length() - 2));
- else
+ } else {
fieldValue.append(newLine);
+ }
newLine = new String(line, 0, i, UtilIO.getUtf8());
}
fields.put(fieldName, fieldValue.toString());
diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/IndentingWriter.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/IndentingWriter.java
index 5e938f9e75..d5d714f9ea 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/IndentingWriter.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/IndentingWriter.java
@@ -47,7 +47,9 @@ public class IndentingWriter extends FilterWriter {
public IndentingWriter newline() throws IOException {
lastWasNewline = true;
- if (doNewline) super.write('\n');
+ if (doNewline) {
+ super.write('\n');
+ }
return this;
}
@@ -76,7 +78,9 @@ public class IndentingWriter extends FilterWriter {
public IndentingWriter space() throws IOException {
checkAfterNewline();
- if (doSpace) super.write(' ');
+ if (doSpace) {
+ super.write(' ');
+ }
return this;
}
diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/JNDIContextFactory.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/JNDIContextFactory.java
index 76b697f6a0..f3a292f6c0 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/JNDIContextFactory.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/JNDIContextFactory.java
@@ -55,17 +55,20 @@ public class JNDIContextFactory {
if (UtilValidate.isEmpty(jndiServerInfo.contextProviderUrl)) {
ic = new InitialContext();
} else {
- Hashtable h = new Hashtable();
+ Hashtable h = new Hashtable<>();
h.put(Context.INITIAL_CONTEXT_FACTORY, jndiServerInfo.initialContextFactory);
h.put(Context.PROVIDER_URL, jndiServerInfo.contextProviderUrl);
- if (UtilValidate.isNotEmpty(jndiServerInfo.urlPkgPrefixes))
+ if (UtilValidate.isNotEmpty(jndiServerInfo.urlPkgPrefixes)) {
h.put(Context.URL_PKG_PREFIXES, jndiServerInfo.urlPkgPrefixes);
+ }
- if (UtilValidate.isNotEmpty(jndiServerInfo.securityPrincipal))
+ if (UtilValidate.isNotEmpty(jndiServerInfo.securityPrincipal)) {
h.put(Context.SECURITY_PRINCIPAL, jndiServerInfo.securityPrincipal);
- if (UtilValidate.isNotEmpty(jndiServerInfo.securityCredentials))
+ }
+ if (UtilValidate.isNotEmpty(jndiServerInfo.securityCredentials)) {
h.put(Context.SECURITY_CREDENTIALS, jndiServerInfo.securityCredentials);
+ }
ic = new InitialContext(h);
}
@@ -88,5 +91,4 @@ public class JNDIContextFactory {
public static void clearInitialContext(String jndiServerName) {
contexts.remove(jndiServerName);
}
-
}
diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/KeyStoreUtil.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/KeyStoreUtil.java
index e20fff0c89..4e91f76154 100755
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/KeyStoreUtil.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/KeyStoreUtil.java
@@ -31,7 +31,6 @@ import java.io.PrintStream;
import java.io.Reader;
import java.io.StringReader;
import java.net.URL;
-import java.nio.charset.StandardCharsets;
import java.security.GeneralSecurityException;
import java.security.KeyFactory;
import java.security.KeyStore;
@@ -145,7 +144,7 @@ public final class KeyStoreUtil {
}
public static Map getX500Map(Principal x500) {
- Map x500Map = new HashMap();
+ Map x500Map = new HashMap<>();
String name = x500.getName().replaceAll("\\\\,", "&com;");
String[] x500Opts = name.split("\\,");
diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/MessageString.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/MessageString.java
index 22c609ebb1..ad0b1d5a08 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/MessageString.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/MessageString.java
@@ -48,23 +48,31 @@ public class MessageString implements Serializable {
if (fieldName == null) {
return Collections.emptyList();
}
- Set fieldSet = new TreeSet();
+ Set fieldSet = new TreeSet<>();
fieldSet.add(fieldName);
return getMessagesForField(fieldSet, convertToStrings, messageStringList);
}
public static List