This is an automated email from the ASF dual-hosted git repository.
surajk pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git The following commit(s) were added to refs/heads/trunk by this push: new d374019 Improved: Corrected all incorrect indentation level issues in framework component, also fixed some case indentation checkstyle issues. (OFBIZ-11922) d374019 is described below commit d374019465231c66823118e20afd6e0f96802a13 Author: Suraj Khurana <[hidden email]> AuthorDate: Sun Jul 26 21:04:41 2020 +0530 Improved: Corrected all incorrect indentation level issues in framework component, also fixed some case indentation checkstyle issues. (OFBIZ-11922) --- .../org/apache/ofbiz/base/util/HttpClient.java | 27 +- .../apache/ofbiz/base/util/MultiTrustManager.java | 16 +- .../org/apache/ofbiz/base/util/ObjectType.java | 14 +- .../ofbiz/base/util/RMIExtendedSocketFactory.java | 2 +- .../org/apache/ofbiz/base/util/StringUtil.java | 2 +- .../org/apache/ofbiz/base/util/TimeDuration.java | 14 +- .../org/apache/ofbiz/base/util/UtilDateTime.java | 6 +- .../java/org/apache/ofbiz/base/util/UtilHttp.java | 4 +- .../org/apache/ofbiz/base/util/UtilNumber.java | 12 +- .../org/apache/ofbiz/base/util/UtilProperties.java | 29 +- .../ofbiz/base/util/cache/CacheListener.java | 6 +- .../apache/ofbiz/base/util/cache/UtilCache.java | 2 +- .../ofbiz/base/util/collections/LocalizedMap.java | 2 +- .../ofbiz/base/util/string/UelFunctions.java | 3 +- .../ofbiz/base/util/template/XslTransform.java | 12 +- .../org/apache/ofbiz/common/CommonServices.java | 16 +- .../java/org/apache/ofbiz/common/FindServices.java | 4 +- .../common/authentication/api/Authenticator.java | 18 +- .../apache/ofbiz/common/email/EmailServices.java | 8 +- .../java/org/apache/ofbiz/datafile/DataFile.java | 3 +- .../apache/ofbiz/datafile/DataFile2EntityXml.java | 3 +- .../java/org/apache/ofbiz/datafile/Record.java | 18 +- .../org/apache/ofbiz/datafile/RecordIterator.java | 6 +- .../apache/ofbiz/entity/condition/OrderByItem.java | 4 +- .../ofbiz/entity/connection/ConnectionFactory.java | 4 +- .../ofbiz/entity/datasource/GenericHelper.java | 26 +- .../apache/ofbiz/entity/eca/EntityEcaHandler.java | 26 +- .../ofbiz/entity/finder/PrimaryKeyFinder.java | 8 +- .../org/apache/ofbiz/entity/jdbc/DatabaseUtil.java | 98 +++--- .../entity/jdbc/ExecQueryCallbackFunctionIF.java | 2 +- .../org/apache/ofbiz/entity/jdbc/SqlJdbcUtil.java | 2 +- .../org/apache/ofbiz/entity/model/ModelEntity.java | 2 +- .../ofbiz/entity/serialize/XmlSerializable.java | 4 +- .../ofbiz/entity/serialize/XmlSerializer.java | 3 +- .../apache/ofbiz/entity/test/EntityTestSuite.java | 22 +- .../entity/transaction/TransactionFactory.java | 10 +- .../org/apache/ofbiz/entity/util/EntityQuery.java | 6 +- .../entityext/data/EntityDataLoadContainer.java | 2 +- .../ofbiz/entityext/eca/EntityEcaCondition.java | 28 +- .../apache/ofbiz/entityext/eca/EntityEcaRule.java | 2 +- .../permission/EntityPermissionChecker.java | 353 +++++++++++---------- .../ofbiz/minilang/method/envops/Iterate.java | 6 +- .../ofbiz/minilang/method/envops/IterateMap.java | 8 +- .../apache/ofbiz/minilang/test/MiniLangTests.java | 2 +- .../org/apache/ofbiz/security/SecurityFactory.java | 10 +- .../org/apache/ofbiz/service/GenericRequester.java | 4 +- .../ofbiz/service/GenericServiceCallback.java | 8 +- .../ofbiz/service/LocalDispatcherFactory.java | 2 +- .../org/apache/ofbiz/service/ModelPermission.java | 2 +- .../apache/ofbiz/service/ServiceDispatcher.java | 11 +- .../service/calendar/TemporalExpressions.java | 36 +-- .../ofbiz/service/engine/XMLRPCClientEngine.java | 2 +- .../ofbiz/base/start/StartupCommandUtil.java | 10 +- .../apache/ofbiz/webapp/control/JWTManager.java | 4 +- .../apache/ofbiz/webapp/control/LoginWorker.java | 3 +- .../ofbiz/webapp/control/RequestHandler.java | 45 +-- .../apache/ofbiz/webapp/event/EventHandler.java | 4 +- .../ofbiz/webapp/event/RequestBodyMapHandler.java | 2 +- .../org/apache/ofbiz/webapp/view/ViewHandler.java | 8 +- .../apache/ofbiz/webtools/WebToolsServices.java | 12 +- .../ofbiz/widget/model/AbstractModelCondition.java | 3 +- .../ofbiz/widget/model/IterateSectionWidget.java | 2 +- .../apache/ofbiz/widget/model/ModelMenuAction.java | 38 +-- .../ofbiz/widget/model/ModelWidgetCondition.java | 3 +- .../ofbiz/widget/portal/PortalPageWorker.java | 12 +- .../apache/ofbiz/widget/renderer/FormRenderer.java | 2 +- .../ofbiz/widget/renderer/FormStringRenderer.java | 144 ++++----- .../ofbiz/widget/renderer/MenuWrapTransform.java | 2 +- .../ofbiz/widget/renderer/ScreenRenderer.java | 2 +- .../ofbiz/widget/renderer/TreeStringRenderer.java | 14 +- .../widget/renderer/html/HtmlMenuRenderer.java | 12 +- .../widget/renderer/html/HtmlMenuWrapper.java | 2 +- .../widget/renderer/html/HtmlMenuWrapperImage.java | 9 +- .../widget/renderer/macro/MacroFormRenderer.java | 2 +- .../widget/renderer/macro/MacroScreenRenderer.java | 170 +++++----- 75 files changed, 709 insertions(+), 716 deletions(-) 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 8b71654..680fa7f 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 @@ -352,8 +352,8 @@ public class HttpClient { try { if (Debug.verboseOn() || debug) { try { - Debug.logVerbose("ContentEncoding: " + con.getContentEncoding() + "; ContentType: " + - con.getContentType() + " or: " + URLConnection.guessContentTypeFromStream(in), MODULE); + 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); } @@ -393,24 +393,23 @@ public class HttpClient { } } - try ( - BufferedReader post = new BufferedReader(charset == null ? new InputStreamReader(in) + try (BufferedReader post = new BufferedReader(charset == null ? new InputStreamReader(in) : new InputStreamReader(in, charset))) { - String line = ""; + String line = ""; - if (Debug.verboseOn() || debug) { - Debug.logVerbose("---- HttpClient Response Content ----", MODULE); - } - while ((line = post.readLine()) != null) { if (Debug.verboseOn() || debug) { - Debug.logVerbose("[HttpClient] : " + line, MODULE); + Debug.logVerbose("---- HttpClient Response Content ----", MODULE); } - buf.append(line); - if (lineFeed) { - buf.append("\n"); + while ((line = post.readLine()) != null) { + if (Debug.verboseOn() || debug) { + Debug.logVerbose("[HttpClient] : " + line, MODULE); + } + buf.append(line); + if (lineFeed) { + buf.append("\n"); + } } } - } } catch (RuntimeException e) { throw e; } catch (Exception e) { diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/MultiTrustManager.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/MultiTrustManager.java index 56370ad..71f5b02 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/MultiTrustManager.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/MultiTrustManager.java @@ -117,16 +117,16 @@ public class MultiTrustManager implements X509TrustManager { protected boolean isTrusted(X509Certificate[] cert) { if (cert != null) { X509Certificate[] issuers = this.getAcceptedIssuers(); - for (X509Certificate issuer: issuers) { - for (X509Certificate c: cert) { + for (X509Certificate issuer : issuers) { + for (X509Certificate c : cert) { + if (Debug.verboseOn()) { + Debug.logVerbose("--- Checking cert: " + issuer.getSubjectX500Principal() + " vs " + c.getSubjectX500Principal(), MODULE); + } + if (issuer.equals(c)) { if (Debug.verboseOn()) { - Debug.logVerbose("--- Checking cert: " + issuer.getSubjectX500Principal() + " vs " + c.getSubjectX500Principal(), MODULE); + Debug.logVerbose("--- Found trusted cert: " + issuer.getSerialNumber().toString(16) + " : " + issuer.getSubjectX500Principal(), MODULE); } - if (issuer.equals(c)) { - if (Debug.verboseOn()) { - Debug.logVerbose("--- Found trusted cert: " + issuer.getSerialNumber().toString(16) + " : " + issuer.getSubjectX500Principal(), MODULE); - } - return true; + return true; } } } diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java index cbb2139..b32227d 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/ObjectType.java @@ -120,13 +120,13 @@ public class ObjectType { if (className.endsWith("[]")) { if (Character.isLowerCase(className.charAt(0)) && className.indexOf(".") < 0) { String prefix = className.substring(0, 1).toUpperCase(Locale.getDefault()); - // long and boolean have other prefix than first letter - if (className.startsWith("long")) { - prefix = "J"; - } else if (className.startsWith("boolean")) { - prefix = "Z"; - } - className = "[" + prefix; + // long and boolean have other prefix than first letter + if (className.startsWith("long")) { + prefix = "J"; + } else if (className.startsWith("boolean")) { + prefix = "Z"; + } + className = "[" + prefix; } else { Class<?> arrayClass = loadClass(className.replace("[]", ""), loader); className = "[L" + arrayClass.getName().replace("[]", "") + ";"; diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/RMIExtendedSocketFactory.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/RMIExtendedSocketFactory.java index 44d0fca..abc9d8c 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/RMIExtendedSocketFactory.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/RMIExtendedSocketFactory.java @@ -87,7 +87,7 @@ public class RMIExtendedSocketFactory extends RMISocketFactory { @Override public ServerSocket createServerSocket(int port) throws IOException { - if (hostInetAddress != null) { + if (hostInetAddress != null) { return new ServerSocket(port, 0, hostInetAddress); } return new ServerSocket(port); diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java index c8ad552..60d2f67 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/StringUtil.java @@ -124,7 +124,7 @@ public class StringUtil { return null; } - st = (delim != null? new StringTokenizer(str, delim): new StringTokenizer(str)); + st = (delim != null ? new StringTokenizer(str, delim) : new StringTokenizer(str)); if (st.hasMoreTokens()) { splitList = new LinkedList<>(); diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/TimeDuration.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/TimeDuration.java index b4f9960..97bb963 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/TimeDuration.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/TimeDuration.java @@ -387,13 +387,13 @@ public class TimeDuration implements Serializable, Comparable<TimeDuration> { */ public static long toLong(TimeDuration duration) { return - (0x757B12C00L * duration.years) + - (0x9CA41900L * duration.months) + - (86400000 * (long) duration.days) + - (3600000 * (long) duration.hours) + - (60000 * (long) duration.minutes) + - (1000 * (long) duration.seconds) + - duration.milliseconds; + (0x757B12C00L * duration.years) + + (0x9CA41900L * duration.months) + + (86400000 * (long) duration.days) + + (3600000 * (long) duration.hours) + + (60000 * (long) duration.minutes) + + (1000 * (long) duration.seconds) + + duration.milliseconds; } protected static class NullDuration extends TimeDuration { diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilDateTime.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilDateTime.java index 77596ea..9e36d8d 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilDateTime.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilDateTime.java @@ -70,15 +70,15 @@ public final class UtilDateTime { } public static int getIntervalInDays(Timestamp from, Timestamp thru) { - return thru != null ? (int) ((thru.getTime() - from.getTime()) / (24*60*60*1000)) : 0; + return thru != null ? (int) ((thru.getTime() - from.getTime()) / (24 * 60 * 60 * 1000)) : 0; } public static Timestamp addDaysToTimestamp(Timestamp start, int days) { - return new Timestamp(start.getTime() + (24L*60L*60L*1000L*days)); + return new Timestamp(start.getTime() + (24L * 60L * 60L * 1000L * days)); } public static Timestamp addDaysToTimestamp(Timestamp start, Double days) { - return new Timestamp(start.getTime() + ((int) (24L*60L*60L*1000L*days))); + return new Timestamp(start.getTime() + ((int) (24L * 60L * 60L * 1000L * days))); } public static double getInterval(Timestamp from, Timestamp thru) { diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java index d565eb1..de23af1 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java @@ -333,7 +333,7 @@ public final class UtilHttp { paramMap.put(name, paramValue); } else { if (paramMap.get(name) instanceof Collection<?>) { - List<String> valueList = UtilGenerics.cast(paramMap.get(name)); + List<String> valueList = UtilGenerics.cast(paramMap.get(name)); valueList.add(paramValue); paramMap.put(name, valueList); } else { @@ -1532,7 +1532,7 @@ public final class UtilHttp { String maxRowIndex = ""; int rowDelimiterLength = MULTI_ROW_DELIMITER.length(); for (String parameterName: requestMap.keySet()) { - int rowDelimiterIndex = (parameterName != null? parameterName.indexOf(MULTI_ROW_DELIMITER): -1); + int rowDelimiterIndex = (parameterName != null ? parameterName.indexOf(MULTI_ROW_DELIMITER) : -1); if (rowDelimiterIndex > 0) { String thisRowIndex = parameterName.substring(rowDelimiterIndex + rowDelimiterLength); if (thisRowIndex.indexOf("_") > -1) { diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java index ae8d063..9b7ba95 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilNumber.java @@ -117,7 +117,7 @@ public final class UtilNumber { // ICU4J rule sets for the en_IN locale. To add more rules, expand this string. // For reference, see the RbnfSampleRuleSets.java file distributed with ICU4J - public static final String RULE_SET_EN_IN = + public static final String RULE_SET_EN_IN = /* * These rules format a number in one of the two styles often used * on checks. %simplified formats paise as hundredths of @@ -190,11 +190,11 @@ public final class UtilNumber { int scale = -1; String value = UtilProperties.getPropertyValue(file, property); - try { - scale = Integer.parseInt(value); - } catch (NumberFormatException e) { - Debug.logWarning(e, e.getMessage(), MODULE); - } + try { + scale = Integer.parseInt(value); + } catch (NumberFormatException e) { + Debug.logWarning(e, e.getMessage(), MODULE); + } if (scale == -1) { Debug.logWarning("Could not set decimal precision from " + property + "=" + value + ". Using default scale of " + DEFAULT_BD_SCALE + ".", MODULE); scale = DEFAULT_BD_SCALE; diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java index 16f0fbd..68af757 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilProperties.java @@ -486,24 +486,27 @@ public final class UtilProperties implements Serializable { return value == null ? "" : value.trim(); } - /** Sets the specified value of the specified property name to the specified resource/properties in memory, does not persist it - * @param resource The name of the resource - * @param name The name of the property in the resource - * @param value The value of the property to set in memory */ - public static void setPropertyValueInMemory(String resource, String name, String value) { - if (UtilValidate.isEmpty(resource)) { + /** + * Sets the specified value of the specified property name to the specified resource/properties in memory, does not persist it + * + * @param resource The name of the resource + * @param name The name of the property in the resource + * @param value The value of the property to set in memory + */ + public static void setPropertyValueInMemory(String resource, String name, String value) { + if (UtilValidate.isEmpty(resource)) { return; } - if (UtilValidate.isEmpty(name)) { + if (UtilValidate.isEmpty(name)) { return; } - Properties properties = getProperties(resource); - if (properties == null) { - return; - } - properties.setProperty(name, value); - } + Properties properties = getProperties(resource); + if (properties == null) { + return; + } + properties.setProperty(name, value); + } // ========= Locale & Resource Based Methods ========== diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/cache/CacheListener.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/cache/CacheListener.java index cd3592e..bb85fb1 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/cache/CacheListener.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/cache/CacheListener.java @@ -20,9 +20,9 @@ package org.apache.ofbiz.base.util.cache; public interface CacheListener<K, V> { - public void noteKeyRemoval(UtilCache<K, V> cache, K key, V oldValue); + void noteKeyRemoval(UtilCache<K, V> cache, K key, V oldValue); - public void noteKeyAddition(UtilCache<K, V> cache, K key, V newValue); + void noteKeyAddition(UtilCache<K, V> cache, K key, V newValue); - public void noteKeyUpdate(UtilCache<K, V> cache, K key, V newValue, V oldValue); + void noteKeyUpdate(UtilCache<K, V> cache, K key, V newValue, V oldValue); } diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/cache/UtilCache.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/cache/UtilCache.java index 3302d7f..28cfaaf 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/cache/UtilCache.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/cache/UtilCache.java @@ -227,7 +227,7 @@ public class UtilCache<K, V> implements Serializable, EvictionListener<Object, C public V putIfAbsentAndGet(K key, V value) { V cachedValue = putIfAbsent(key, value); - return (cachedValue != null? cachedValue: value); + return (cachedValue != null ? cachedValue : value); } CacheLine<V> createSoftRefCacheLine(final Object key, V value, long loadTimeNanos, long expireTimeNanos) { diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/LocalizedMap.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/LocalizedMap.java index 0cfc218..40c6c2b 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/LocalizedMap.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/collections/LocalizedMap.java @@ -25,5 +25,5 @@ import java.util.Locale; * */ public interface LocalizedMap<V> { - public V get(String name, Locale locale); + V get(String name, Locale locale); } diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelFunctions.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelFunctions.java index e632400..1f8f6d5 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelFunctions.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/string/UelFunctions.java @@ -445,8 +445,7 @@ public class UelFunctions { if (url != null) { try (InputStream is = url.openStream();) { document = UtilXml.readXmlDocument(is, str); - } - catch (SAXException | ParserConfigurationException e) { + } catch (SAXException | ParserConfigurationException e) { Debug.logError(e, "Error while reading XML document " + str, MODULE); } } else { diff --git a/framework/base/src/main/java/org/apache/ofbiz/base/util/template/XslTransform.java b/framework/base/src/main/java/org/apache/ofbiz/base/util/template/XslTransform.java index e754718..8fb83c8 100644 --- a/framework/base/src/main/java/org/apache/ofbiz/base/util/template/XslTransform.java +++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/template/XslTransform.java @@ -83,9 +83,9 @@ public final class XslTransform { Transformer transformer = tfactory.newTransformer(new StreamSource(template)); // and apply the xsl template to the source document and save in a result string try (StringWriter sw = new StringWriter()) { - StreamResult sr = new StreamResult(sw); - transformer.transform(source, sr); - result = sw.toString(); + StreamResult sr = new StreamResult(sw); + transformer.transform(source, sr); + result = sw.toString(); } catch (IOException e) { Debug.logError(e, MODULE); } @@ -123,11 +123,11 @@ public final class XslTransform { if (translet != null) { Transformer transformer = translet.newTransformer(); if (params != null) { - for (Map.Entry<String, Object> entry: params.entrySet()) { - String key = entry.getKey(); + for (Map.Entry<String, Object> entry : params.entrySet()) { + String key = entry.getKey(); Object val = entry.getValue(); transformer.setParameter(key, val); - } + } } DOMResult outputResult = new DOMResult(UtilXml.makeEmptyXmlDocument()); diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/CommonServices.java b/framework/common/src/main/java/org/apache/ofbiz/common/CommonServices.java index 587e138..5933344 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/CommonServices.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/CommonServices.java @@ -226,12 +226,12 @@ public class CommonServices { * Echo service; returns exactly what was sent. * This service does not have required parameters and does not validate */ - public static Map<String, Object> echoService(DispatchContext dctx, Map<String, ?> context) { - Map<String, Object> result = new LinkedHashMap<>(); - result.putAll(context); - result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS); - return result; - } + public static Map<String, Object> echoService(DispatchContext dctx, Map<String, ?> context) { + Map<String, Object> result = new LinkedHashMap<>(); + result.putAll(context); + result.put(ModelService.RESPONSE_MESSAGE, ModelService.RESPOND_SUCCESS); + return result; + } /** * Return Error Service; Used for testing error handling @@ -448,10 +448,10 @@ public class CommonServices { MimeMessage message = wrapper.getMessage(); try { if (message.getAllRecipients() != null) { - Debug.logInfo("To: " + UtilMisc.toListArray(message.getAllRecipients()), MODULE); + Debug.logInfo("To: " + UtilMisc.toListArray(message.getAllRecipients()), MODULE); } if (message.getFrom() != null) { - Debug.logInfo("From: " + UtilMisc.toListArray(message.getFrom()), MODULE); + Debug.logInfo("From: " + UtilMisc.toListArray(message.getFrom()), MODULE); } Debug.logInfo("Subject: " + message.getSubject(), MODULE); if (message.getSentDate() != null) { diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/FindServices.java b/framework/common/src/main/java/org/apache/ofbiz/common/FindServices.java index 80a0f13..65c08b8 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/FindServices.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/FindServices.java @@ -100,7 +100,7 @@ public class FindServices { public static Map<String, Map<String, Map<String, Object>>> prepareField(Map<String, ?> inputFields, Map<String, Object> queryStringMap, Map<String, List<Object[]>> origValueMap) { // Strip the "_suffix" off of the parameter name and // build a three-level map of values keyed by fieldRoot name, - // fld0 or fld1, and, then, "op" or "value" + // fld0 or fld1, and, then, "op" or "value" // ie. id // - fld0 // - op:like @@ -728,7 +728,7 @@ public class FindServices { public static Map<String, Object> buildReducedQueryString(Map<String, ?> inputFields, String entityName, Delegator delegator) { // Strip the "_suffix" off of the parameter name and // build a three-level map of values keyed by fieldRoot name, - // fld0 or fld1, and, then, "op" or "value" + // fld0 or fld1, and, then, "op" or "value" // ie. id // - fld0 // - op:like diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/authentication/api/Authenticator.java b/framework/common/src/main/java/org/apache/ofbiz/common/authentication/api/Authenticator.java index 8af1a65..b21b7b5 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/authentication/api/Authenticator.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/authentication/api/Authenticator.java @@ -35,7 +35,7 @@ public interface Authenticator { * object can be obtained from the LocalDispatcher) * @param dispatcher The LocalDispatcher to use for this Authenticator */ - public void initialize(LocalDispatcher dispatcher); + void initialize(LocalDispatcher dispatcher); /** * Method to authenticate a user @@ -45,14 +45,14 @@ public interface Authenticator { * @return true if the user is authenticated * @throws AuthenticatorException when a fatal error occurs during authentication */ - public boolean authenticate(String username, String password, boolean isServiceAuth) throws AuthenticatorException; + boolean authenticate(String username, String password, boolean isServiceAuth) throws AuthenticatorException; /** * Logs a user out * @param username User's username * @throws AuthenticatorException when logout fails */ - public void logout(String username) throws AuthenticatorException; + void logout(String username) throws AuthenticatorException; /** * Reads user information and syncs it to OFBiz (i.e. UserLogin, Person, etc) @@ -60,7 +60,7 @@ public interface Authenticator { * @param username User's username * @throws AuthenticatorException user synchronization fails */ - public void syncUser(String username) throws AuthenticatorException; + void syncUser(String username) throws AuthenticatorException; /** * Updates a user's password @@ -69,29 +69,29 @@ public interface Authenticator { * @param newPassword User's new password * @throws AuthenticatorException when update password fails */ - public void updatePassword(String username, String password, String newPassword) throws AuthenticatorException; + void updatePassword(String username, String password, String newPassword) throws AuthenticatorException; /** * Weight of this authenticator (lower weights are run first) * @return the weight of this Authenticator */ - public float getWeight(); + float getWeight(); /** * Is the user synchronized back to OFBiz * @return true if the user record is copied to the OFB database */ - public boolean isUserSynchronized(); + boolean isUserSynchronized(); /** * Is this expected to be the only authenticator, if so errors will be thrown when users cannot be found * @return true if this is expected to be the only Authenticator */ - public boolean isSingleAuthenticator(); + boolean isSingleAuthenticator(); /** * Flag to test if this Authenticator is enabled * @return true if the Authenticator is enabled */ - public boolean isEnabled(); + boolean isEnabled(); } diff --git a/framework/common/src/main/java/org/apache/ofbiz/common/email/EmailServices.java b/framework/common/src/main/java/org/apache/ofbiz/common/email/EmailServices.java index 3b00945..18a2916 100644 --- a/framework/common/src/main/java/org/apache/ofbiz/common/email/EmailServices.java +++ b/framework/common/src/main/java/org/apache/ofbiz/common/email/EmailServices.java @@ -166,8 +166,8 @@ public class EmailServices { String sendType = (String) context.get("sendType"); String port = (String) context.get("port"); String socketFactoryClass = (String) context.get("socketFactoryClass"); - String socketFactoryPort = (String) context.get("socketFactoryPort"); - String socketFactoryFallback = (String) context.get("socketFactoryFallback"); + String socketFactoryPort = (String) context.get("socketFactoryPort"); + String socketFactoryFallback = (String) context.get("socketFactoryFallback"); String sendVia = (String) context.get("sendVia"); String authUser = (String) context.get("authUser"); String authPass = (String) context.get("authPass"); @@ -524,7 +524,7 @@ public class EmailServices { if (UtilValidate.isNotEmpty(xslfoAttachScreenLocationList)) { List<Map<String, ? extends Object>> bodyParts = new LinkedList<>(); if (bodyText != null) { - bodyText = FlexibleStringExpander.expandString(bodyText, screenContext, locale); + bodyText = FlexibleStringExpander.expandString(bodyText, screenContext, locale); bodyParts.add(UtilMisc.<String, Object>toMap("content", bodyText, "type", UtilValidate.isNotEmpty(contentType) ? contentType : "text/html")); } else { bodyParts.add(UtilMisc.<String, Object>toMap("content", bodyWriter.toString(), "type", UtilValidate.isNotEmpty(contentType) ? contentType : "text/html")); @@ -580,7 +580,7 @@ public class EmailServices { isMultiPart = false; // store body and type for single part message in the context. if (bodyText != null) { - bodyText = FlexibleStringExpander.expandString(bodyText, screenContext, locale); + bodyText = FlexibleStringExpander.expandString(bodyText, screenContext, locale); serviceContext.put("body", bodyText); } else { serviceContext.put("body", bodyWriter.toString()); diff --git a/framework/datafile/src/main/java/org/apache/ofbiz/datafile/DataFile.java b/framework/datafile/src/main/java/org/apache/ofbiz/datafile/DataFile.java index fea8819..2c9dcc8 100644 --- a/framework/datafile/src/main/java/org/apache/ofbiz/datafile/DataFile.java +++ b/framework/datafile/src/main/java/org/apache/ofbiz/datafile/DataFile.java @@ -218,8 +218,7 @@ public class DataFile { try { outStream.write(line.getBytes(StandardCharsets.UTF_8)); - } - catch (IOException e) { + } catch (IOException e) { throw new DataFileException("Could not write to stream;", e); } diff --git a/framework/datafile/src/main/java/org/apache/ofbiz/datafile/DataFile2EntityXml.java b/framework/datafile/src/main/java/org/apache/ofbiz/datafile/DataFile2EntityXml.java index c34820b..5dd7c94 100644 --- a/framework/datafile/src/main/java/org/apache/ofbiz/datafile/DataFile2EntityXml.java +++ b/framework/datafile/src/main/java/org/apache/ofbiz/datafile/DataFile2EntityXml.java @@ -103,8 +103,7 @@ public class DataFile2EntityXml { if (dataFileUrl != null && definitionUrl != null && UtilValidate.isNotEmpty(definitionName)) { try { dataFile = DataFile.readFile(dataFileUrl, definitionUrl, definitionName); - } - catch (DataFileException e) { + } catch (DataFileException e) { Debug.logError("Error Occurred while reading Datafile, Exception: " + e, MODULE); } } diff --git a/framework/datafile/src/main/java/org/apache/ofbiz/datafile/Record.java b/framework/datafile/src/main/java/org/apache/ofbiz/datafile/Record.java index 8375c8d..ef92968 100644 --- a/framework/datafile/src/main/java/org/apache/ofbiz/datafile/Record.java +++ b/framework/datafile/src/main/java/org/apache/ofbiz/datafile/Record.java @@ -511,20 +511,17 @@ public class Record implements Serializable { try { strVal = line.substring(modelField.position, modelField.position + modelField.length); - } - catch (IndexOutOfBoundsException ioobe) { + } catch (IndexOutOfBoundsException ioobe) { throw new DataFileException("Field " + modelField.name + " from " + modelField.position + " for " + modelField.length + " chars could not be read from a line (" + lineNum + ") with only " + line.length() + " chars.", ioobe); } try { record.setString(modelField.name, strVal); - } - catch (java.text.ParseException e) { + } catch (java.text.ParseException e) { throw new DataFileException( "Could not parse field " + modelField.name + ", format string \"" + modelField.format + "\" with value " + strVal + " on line " + lineNum, e); - } - catch (java.lang.NumberFormatException e) { + } catch (java.lang.NumberFormatException e) { throw new DataFileException( "Number not valid for field " + modelField.name + ", format string \"" + modelField.format + "\" with value " + strVal + " on line " + lineNum, e); } @@ -569,8 +566,7 @@ public class Record implements Serializable { } else if (st.hasMoreTokens()) { st.nextToken(); } - } - catch (NoSuchElementException nsee) { + } catch (NoSuchElementException nsee) { throw new DataFileException("Field " + modelField.name + " could not be read from a line (" + lineNum + ") with only " + line.length() + " chars.", nsee); } } @@ -587,12 +583,10 @@ public class Record implements Serializable { strVal = strVal.substring(textDelimiter.length(), strVal.length() - textDelimiter.length()); } record.setString(modelField.name, strVal); - } - catch (java.text.ParseException e) { + } catch (java.text.ParseException e) { throw new DataFileException( "Could not parse field " + modelField.name + ", format string \"" + modelField.format + "\" with value " + strVal + " on line " + lineNum, e); - } - catch (java.lang.NumberFormatException e) { + } catch (java.lang.NumberFormatException e) { throw new DataFileException( "Number not valid for field " + modelField.name + ", format string \"" + modelField.format + "\" with value " + strVal + " on line " + lineNum, e); } diff --git a/framework/datafile/src/main/java/org/apache/ofbiz/datafile/RecordIterator.java b/framework/datafile/src/main/java/org/apache/ofbiz/datafile/RecordIterator.java index 48f9a8e..6ee686d 100644 --- a/framework/datafile/src/main/java/org/apache/ofbiz/datafile/RecordIterator.java +++ b/framework/datafile/src/main/java/org/apache/ofbiz/datafile/RecordIterator.java @@ -105,8 +105,7 @@ public class RecordIterator { } else { nextLine = new String(charData); } - } - catch (IOException e) { + } catch (IOException e) { throw new DataFileException("Error reading line #" + nextLineNum + " (index " + (nextLineNum - 1) * modelDataFile.recordLength + " length " + modelDataFile.recordLength + ") from location: " + locationInfo, e); @@ -114,8 +113,7 @@ public class RecordIterator { } else { try { nextLine = br.readLine(); - } - catch (IOException e) { + } catch (IOException e) { throw new DataFileException("Error reading line #" + nextLineNum + " from location: " + locationInfo, e); } } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByItem.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByItem.java index de4d6fa..fee159d 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByItem.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/condition/OrderByItem.java @@ -30,8 +30,8 @@ import org.apache.ofbiz.entity.model.ModelEntity; public class OrderByItem implements Comparator<GenericEntity> { public static final int DEFAULT = 0; - public static final int UPPER = 1; - public static final int LOWER = 2; + public static final int UPPER = 1; + public static final int LOWER = 2; public static final String NULLS_FIRST = "NULLS FIRST"; public static final String NULLS_LAST = "NULLS LAST"; diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/connection/ConnectionFactory.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/connection/ConnectionFactory.java index cedd835..147f5f7 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/connection/ConnectionFactory.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/connection/ConnectionFactory.java @@ -30,6 +30,6 @@ import org.apache.ofbiz.entity.datasource.GenericHelperInfo; */ public interface ConnectionFactory { - public Connection getConnection(GenericHelperInfo helperInfo, JdbcElement jdbcElement) throws SQLException, GenericEntityException; - public void closeAll(); + Connection getConnection(GenericHelperInfo helperInfo, JdbcElement jdbcElement) throws SQLException, GenericEntityException; + void closeAll(); } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/datasource/GenericHelper.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/datasource/GenericHelper.java index 3eb9a0f..f14bec7 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/datasource/GenericHelper.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/datasource/GenericHelper.java @@ -46,39 +46,39 @@ public interface GenericHelper { /** Gets the name of the server configuration that corresponds to this helper *@return server configuration name */ - public String getHelperName(); + String getHelperName(); /** Creates a Entity in the form of a GenericValue and write it to the database *@return GenericValue instance containing the new instance */ - public GenericValue create(GenericValue value) throws GenericEntityException; + GenericValue create(GenericValue value) throws GenericEntityException; /** Find a Generic Entity by its Primary Key *@param primaryKey The primary key to find by. *@return The GenericValue corresponding to the primaryKey */ - public GenericValue findByPrimaryKey(GenericPK primaryKey) throws GenericEntityException; + GenericValue findByPrimaryKey(GenericPK primaryKey) throws GenericEntityException; /** Find a Generic Entity by its Primary Key and only returns the values requested by the passed keys (names) *@param primaryKey The primary key to find by. *@param keys The keys, or names, of the values to retrieve; only these values will be retrieved *@return The GenericValue corresponding to the primaryKey */ - public GenericValue findByPrimaryKeyPartial(GenericPK primaryKey, Set<String> keys) throws GenericEntityException; + GenericValue findByPrimaryKeyPartial(GenericPK primaryKey, Set<String> keys) throws GenericEntityException; /** Find a number of Generic Value objects by their Primary Keys, all at once *@param primaryKeys A List of primary keys to find by. *@return List of GenericValue objects corresponding to the passed primaryKey objects */ - public List<GenericValue> findAllByPrimaryKeys(List<GenericPK> primaryKeys) throws GenericEntityException; + List<GenericValue> findAllByPrimaryKeys(List<GenericPK> primaryKeys) throws GenericEntityException; /** Remove a Generic Entity corresponding to the primaryKey *@param primaryKey The primary key of the entity to remove. *@return int representing number of rows effected by this operation */ - public int removeByPrimaryKey(GenericPK primaryKey) throws GenericEntityException; + int removeByPrimaryKey(GenericPK primaryKey) throws GenericEntityException; - public List<GenericValue> findByMultiRelation(GenericValue value, ModelRelation modelRelationOne, ModelEntity modelEntityOne, + List<GenericValue> findByMultiRelation(GenericValue value, ModelRelation modelRelationOne, ModelEntity modelEntityOne, ModelRelation modelRelationTwo, ModelEntity modelEntityTwo, List<String> orderBy) throws GenericEntityException; /** Finds GenericValues by the conditions specified in the EntityCondition object, the the EntityCondition javadoc for more details. @@ -92,11 +92,11 @@ public interface GenericHelper { * DONE WITH IT (preferably in a finally block), * AND DON'T LEAVE IT OPEN TOO LONG BECAUSE IT WILL MAINTAIN A DATABASE CONNECTION. */ - public EntityListIterator findListIteratorByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, + EntityListIterator findListIteratorByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, Collection<String> fieldsToSelect, List<String> orderBy, EntityFindOptions findOptions) throws GenericEntityException; - public long findCountByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, + long findCountByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, EntityCondition havingEntityCondition, EntityFindOptions findOptions) throws GenericEntityException; long findCountByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition whereEntityCondition, @@ -108,7 +108,7 @@ public interface GenericHelper { *@param condition The condition that restricts the list of removed values *@return int representing number of rows effected by this operation */ - public int removeByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition condition) throws GenericEntityException; + int removeByCondition(Delegator delegator, ModelEntity modelEntity, EntityCondition condition) throws GenericEntityException; /** Stores a group of values in a single query *@param modelEntity The ModelEntity of the Entity as defined in the entity XML file @@ -117,18 +117,18 @@ public interface GenericHelper { *@return int representing number of rows effected by this operation *@throws GenericEntityException */ - public int storeByCondition(Delegator delegator, ModelEntity modelEntity, Map<String, ? extends Object> fieldsToSet, EntityCondition condition) throws GenericEntityException; + int storeByCondition(Delegator delegator, ModelEntity modelEntity, Map<String, ? extends Object> fieldsToSet, EntityCondition condition) throws GenericEntityException; /** Store the Entity from the GenericValue to the persistent store *@param value GenericValue instance containing the entity *@return int representing number of rows effected by this operation */ - public int store(GenericValue value) throws GenericEntityException; + int store(GenericValue value) throws GenericEntityException; /** Check the datasource to make sure the entity definitions are correct, optionally adding missing entities or fields on the server *@param modelEntities Map of entityName names and ModelEntity values *@param messages List to put any result messages in *@param addMissing Flag indicating whether or not to add missing entities and fields on the server */ - public void checkDataSource(Map<String, ModelEntity> modelEntities, List<String> messages, boolean addMissing) throws GenericEntityException; + void checkDataSource(Map<String, ModelEntity> modelEntities, List<String> messages, boolean addMissing) throws GenericEntityException; } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/eca/EntityEcaHandler.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/eca/EntityEcaHandler.java index 3a4c754..ec330a2 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/eca/EntityEcaHandler.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/eca/EntityEcaHandler.java @@ -31,25 +31,25 @@ import org.apache.ofbiz.entity.GenericEntityException; */ public interface EntityEcaHandler<T> { - public static final String EV_VALIDATE = "validate"; - public static final String EV_RUN = "run"; - public static final String EV_RETURN = "return"; + String EV_VALIDATE = "validate"; + String EV_RUN = "run"; + String EV_RETURN = "return"; /** * Invoked after the entity operation, but before the cache is cleared. */ - public static final String EV_CACHE_CLEAR = "cache-clear"; - public static final String EV_CACHE_CHECK = "cache-check"; - public static final String EV_CACHE_PUT = "cache-put"; + String EV_CACHE_CLEAR = "cache-clear"; + String EV_CACHE_CHECK = "cache-check"; + String EV_CACHE_PUT = "cache-put"; - public static final String OP_CREATE = "create"; - public static final String OP_STORE = "store"; - public static final String OP_REMOVE = "remove"; - public static final String OP_FIND = "find"; + String OP_CREATE = "create"; + String OP_STORE = "store"; + String OP_REMOVE = "remove"; + String OP_FIND = "find"; - public void setDelegator(Delegator delegator); + void setDelegator(Delegator delegator); - public Map<String, List<T>> getEntityEventMap(String entityName); + Map<String, List<T>> getEntityEventMap(String entityName); - public void evalRules(String currentOperation, Map<String, List<T>> eventMap, String event, GenericEntity value, boolean isError) throws GenericEntityException; + void evalRules(String currentOperation, Map<String, List<T>> eventMap, String event, GenericEntity value, boolean isError) throws GenericEntityException; } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/PrimaryKeyFinder.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/PrimaryKeyFinder.java index db15212..17e43dc 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/PrimaryKeyFinder.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/finder/PrimaryKeyFinder.java @@ -87,11 +87,11 @@ public class PrimaryKeyFinder extends Finder { GenericValue valueOut = runFind(modelEntity, context, delegator, useCacheBool, autoFieldMapBool, this.fieldMap, this.selectFieldExpanderList); if (!valueNameAcsr.isEmpty()) { - this.valueNameAcsr.put(context, valueOut); + this.valueNameAcsr.put(context, valueOut); } else { - if (valueOut != null) { - context.putAll(valueOut); - } + if (valueOut != null) { + context.putAll(valueOut); + } } } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java index b185b89..dc6f0d3 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/DatabaseUtil.java @@ -318,15 +318,15 @@ public class DatabaseUtil { // NOTE: this may need a toUpperCase in some cases, keep an eye on it, okay just compare with ignore case if (!ccInfo.typeName.equalsIgnoreCase(typeName)) { - String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + - entity.getEntityName() + "] is of type [" + ccInfo.typeName + "] in the database, but is defined as type [" + - typeName + "] in the entity definition."; + String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + + entity.getEntityName() + "] is of type [" + ccInfo.typeName + "] in the database, but is defined as type [" + + typeName + "] in the entity definition."; Debug.logError(message, MODULE); if (messages != null) messages.add(message); } if (columnSize != -1 && ccInfo.columnSize != -1 && columnSize != ccInfo.columnSize && (columnSize * 3) != ccInfo.columnSize) { - String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + - entity.getEntityName() + "] has a column size of [" + ccInfo.columnSize + + String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + + entity.getEntityName() + "] has a column size of [" + ccInfo.columnSize + "] in the database, but is defined to have a column size of [" + columnSize + "] in the entity definition."; Debug.logWarning(message, MODULE); if (messages != null) messages.add(message); @@ -336,8 +336,8 @@ public class DatabaseUtil { } } if (decimalDigits != -1 && decimalDigits != ccInfo.decimalDigits) { - String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + - entity.getEntityName() + "] has a decimalDigits of [" + ccInfo.decimalDigits + + String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + + entity.getEntityName() + "] has a decimalDigits of [" + ccInfo.decimalDigits + "] in the database, but is defined to have a decimalDigits of [" + decimalDigits + "] in the entity definition."; Debug.logWarning(message, MODULE); if (messages != null) messages.add(message); @@ -345,14 +345,14 @@ public class DatabaseUtil { // do primary key matching check if (checkPks && ccInfo.isPk && !field.getIsPk()) { - String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + - entity.getEntityName() + "] IS a primary key in the database, but IS NOT a primary key in the entity definition. The primary key for this table needs to be re-created or modified so that this column is NOT part of the primary key."; + String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + + entity.getEntityName() + "] IS a primary key in the database, but IS NOT a primary key in the entity definition. The primary key for this table needs to be re-created or modified so that this column is NOT part of the primary key."; Debug.logError(message, MODULE); if (messages != null) messages.add(message); } if (checkPks && !ccInfo.isPk && field.getIsPk()) { - String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + - entity.getEntityName() + "] IS NOT a primary key in the database, but IS a primary key in the entity definition. The primary key for this table needs to be re-created or modified to add this column to the primary key. Note that data may need to be added first as a primary key column cannot have an null values."; + String message = "Column [" + ccInfo.columnName + "] of table [" + tableName + "] of entity [" + + entity.getEntityName() + "] IS NOT a primary key in the database, but IS a primary key in the entity definition. The primary key for this table needs to be re-created or modified to add this column to the primary key. Note that data may need to be added first as a primary key column cannot have an null values."; Debug.logError(message, MODULE); if (messages != null) messages.add(message); } @@ -459,13 +459,13 @@ public class DatabaseUtil { List<Future<AbstractCountingCallable>> disFutures = new LinkedList<>(); for (ModelEntity curEntity: entitiesAdded) { if (curEntity.getIndexesSize() > 0) { - disFutures.add(executor.submit(new AbstractCountingCallable(curEntity, modelEntities) { - @Override - public AbstractCountingCallable call() throws Exception { - count = createDeclaredIndices(entity, messages); - return this; - } - })); + disFutures.add(executor.submit(new AbstractCountingCallable(curEntity, modelEntities) { + @Override + public AbstractCountingCallable call() throws Exception { + count = createDeclaredIndices(entity, messages); + return this; + } + })); } } @@ -1200,40 +1200,40 @@ public class DatabaseUtil { public int checkPrimaryKeyInfo(ResultSet rsPks, String lookupSchemaName, boolean needsUpperCase, Map<String, Map<String, ColumnCheckInfo>> colInfo, Collection<String> messages) throws SQLException { int pkCount = 0; - while (rsPks.next()) { - pkCount++; - try { - String tableName = ColumnCheckInfo.fixupTableName(rsPks.getString("TABLE_NAME"), lookupSchemaName, needsUpperCase); - String columnName = rsPks.getString("COLUMN_NAME"); - if (needsUpperCase && columnName != null) { - columnName = columnName.toUpperCase(); - } - Map<String, ColumnCheckInfo> tableColInfo = colInfo.get(tableName); - if (tableColInfo == null) { - // not looking for info on this table - continue; - } - ColumnCheckInfo ccInfo = tableColInfo.get(columnName); - if (ccInfo == null) { - // this isn't good, what to do? - Debug.logWarning("Got primary key information for a column that we didn't get column information for: tableName=[" + tableName + "], columnName=[" + columnName + "]", MODULE); - continue; - } + while (rsPks.next()) { + pkCount++; + try { + String tableName = ColumnCheckInfo.fixupTableName(rsPks.getString("TABLE_NAME"), lookupSchemaName, needsUpperCase); + String columnName = rsPks.getString("COLUMN_NAME"); + if (needsUpperCase && columnName != null) { + columnName = columnName.toUpperCase(); + } + Map<String, ColumnCheckInfo> tableColInfo = colInfo.get(tableName); + if (tableColInfo == null) { + // not looking for info on this table + continue; + } + ColumnCheckInfo ccInfo = tableColInfo.get(columnName); + if (ccInfo == null) { + // this isn't good, what to do? + Debug.logWarning("Got primary key information for a column that we didn't get column information for: tableName=[" + tableName + "], columnName=[" + columnName + "]", MODULE); + continue; + } - // KEY_SEQ short => sequence number within primary key - // PK_NAME String => primary key name (may be null) + // KEY_SEQ short => sequence number within primary key + // PK_NAME String => primary key name (may be null) - ccInfo.isPk = true; - ccInfo.pkSeq = rsPks.getShort("KEY_SEQ"); - ccInfo.pkName = rsPks.getString("PK_NAME"); - } catch (SQLException e) { - String message = "Error getting primary key info for column. Error was:" + e.toString(); - Debug.logError(message, MODULE); - if (messages != null) messages.add(message); - continue; - } + ccInfo.isPk = true; + ccInfo.pkSeq = rsPks.getShort("KEY_SEQ"); + ccInfo.pkName = rsPks.getString("PK_NAME"); + } catch (SQLException e) { + String message = "Error getting primary key info for column. Error was:" + e.toString(); + Debug.logError(message, MODULE); + if (messages != null) messages.add(message); + continue; } + } return pkCount; } @@ -2310,7 +2310,7 @@ public class DatabaseUtil { } } - public void deletePrimaryKey(ModelEntity entity, boolean usePkConstraintNames, List<String> messages) { + public void deletePrimaryKey(ModelEntity entity, boolean usePkConstraintNames, List<String> messages) { deletePrimaryKey(entity, usePkConstraintNames, datasourceInfo.getConstraintNameClipLength(), messages); } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/ExecQueryCallbackFunctionIF.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/ExecQueryCallbackFunctionIF.java index b76fac9..0389bce 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/ExecQueryCallbackFunctionIF.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/ExecQueryCallbackFunctionIF.java @@ -22,5 +22,5 @@ import java.sql.ResultSet; import java.sql.SQLException; public interface ExecQueryCallbackFunctionIF { - public boolean processNextRow(ResultSet rs) throws SQLException; + boolean processNextRow(ResultSet rs) throws SQLException; } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/SqlJdbcUtil.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/SqlJdbcUtil.java index fa32b4d..a00ed12 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/SqlJdbcUtil.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/jdbc/SqlJdbcUtil.java @@ -474,7 +474,7 @@ public final class SqlJdbcUtil { modelViewEntity.populateViewEntityConditionInformation(modelFieldTypeReader, whereConditions, havingConditions, orderByList, null); String viewConditionClause; if (!whereConditions.isEmpty()) { - viewConditionClause = EntityCondition.makeCondition(whereConditions, EntityOperator.AND).makeWhereString(modelViewEntity, null, datasourceInfo); + viewConditionClause = EntityCondition.makeCondition(whereConditions, EntityOperator.AND).makeWhereString(modelViewEntity, null, datasourceInfo); } else { viewConditionClause = null; } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelEntity.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelEntity.java index 832bc05..1700dc6 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelEntity.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/model/ModelEntity.java @@ -972,7 +972,7 @@ public class ModelEntity implements Comparable<ModelEntity>, Serializable { return colNameString(new StringBuilder(), "", flds).toString(); } - public StringBuilder colNameString(StringBuilder sb, String prefix, ModelField... flds) { + public StringBuilder colNameString(StringBuilder sb, String prefix, ModelField... flds) { return colNameString(Arrays.asList(flds), sb, prefix); } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/serialize/XmlSerializable.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/serialize/XmlSerializable.java index c2c271e..d7108bf 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/serialize/XmlSerializable.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/serialize/XmlSerializable.java @@ -31,13 +31,13 @@ public interface XmlSerializable<T> { * @param element XML element * @throws SerializeException */ - public T deserialize(Element element) throws SerializeException; + T deserialize(Element element) throws SerializeException; /** * Serialize the object to an XML element * @throws SerializeException */ - public Element serialize() throws SerializeException; + Element serialize() throws SerializeException; } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/serialize/XmlSerializer.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/serialize/XmlSerializer.java index aa27340..afe81ad 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/serialize/XmlSerializer.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/serialize/XmlSerializer.java @@ -347,8 +347,7 @@ public class XmlSerializer { try { Calendar cal = DatatypeConverter.parseDate(valStr); return new java.sql.Timestamp(cal.getTimeInMillis()); - } - catch (Exception e) { + } catch (Exception e) { Debug.logWarning("sql-Timestamp does not conform to XML Schema definition, try java.sql.Timestamp format", MODULE); return java.sql.Timestamp.valueOf(valStr); } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityTestSuite.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityTestSuite.java index 7fd20e5..41ec2a8 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityTestSuite.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/test/EntityTestSuite.java @@ -418,10 +418,11 @@ public class EntityTestSuite extends EntityTestCase { .where(EntityCondition.makeCondition("description", EntityOperator.LIKE, descriptionPrefix + "%")) .queryList()) { if (i % 2 == 0) { - GenericValue testing = delegator.create("Testing", "testingId", descriptionPrefix + ":" + node.get("testingNodeId"), "testingTypeId", typeId, "description", node.get("description")); + GenericValue testing = delegator.create("Testing", "testingId", descriptionPrefix + ":" + node.get("testingNodeId"), "testingTypeId", + typeId, "description", node.get("description")); GenericValue member = delegator.makeValue("TestingNodeMember", - "testingNodeId", node.get("testingNodeId"), - "testingId", testing.get("testingId")); + "testingNodeId", node.get("testingNodeId"), + "testingId", testing.get("testingId")); member.put("fromDate", now); member.put("thruDate", UtilDateTime.getNextDayStart(now)); @@ -440,9 +441,9 @@ public class EntityTestSuite extends EntityTestCase { createNodeMembers("TEST-COUNT-VIEW", "Testing Type #Count", "count-views"); EntityCondition isNodeWithMember = EntityCondition.makeCondition( - EntityCondition.makeCondition("testingId", EntityOperator.NOT_EQUAL, GenericEntity.NULL_FIELD), - EntityOperator.AND, - EntityCondition.makeCondition("description", EntityOperator.LIKE, "count-views:%")); + EntityCondition.makeCondition("testingId", EntityOperator.NOT_EQUAL, GenericEntity.NULL_FIELD), + EntityOperator.AND, + EntityCondition.makeCondition("description", EntityOperator.LIKE, "count-views:%")); List<GenericValue> nodeWithMembers = EntityQuery.use(delegator).from("TestingNodeAndMember").where(isNodeWithMember).queryList(); for (GenericValue v: nodeWithMembers) { @@ -551,9 +552,12 @@ public class EntityTestSuite extends EntityTestCase { } delegator.removeByCondition("TestingNode", EntityCondition.makeCondition("description", EntityOperator.LIKE, "foreign-key-remove #%")); delegator.create("TestingNode", "testingNodeId", "TEST-FK-REMOVE-0", "description", "foreign-key-remove #0"); - delegator.create("TestingNode", "testingNodeId", "TEST-FK-REMOVE-1", "primaryParentNodeId", "TEST-FK-REMOVE-0", "description", "foreign-key-remove #1"); - delegator.create("TestingNode", "testingNodeId", "TEST-FK-REMOVE-2", "primaryParentNodeId", "TEST-FK-REMOVE-1", "description", "foreign-key-remove #2"); - delegator.create("TestingNode", "testingNodeId", "TEST-FK-REMOVE-3", "primaryParentNodeId", "TEST-FK-REMOVE-2", "description", "foreign-key-remove #3"); + delegator.create("TestingNode", "testingNodeId", "TEST-FK-REMOVE-1", "primaryParentNodeId", "TEST-FK-REMOVE-0", "description", "foreign-key" + + "-remove #1"); + delegator.create("TestingNode", "testingNodeId", "TEST-FK-REMOVE-2", "primaryParentNodeId", "TEST-FK-REMOVE-1", "description", "foreign-key" + + "-remove #2"); + delegator.create("TestingNode", "testingNodeId", "TEST-FK-REMOVE-3", "primaryParentNodeId", "TEST-FK-REMOVE-2", "description", "foreign-key" + + "-remove #3"); GenericEntityException caught = null; try { EntityCondition isLevel1 = EntityCondition.makeCondition("description", EntityOperator.EQUALS, "foreign-key-remove #1"); diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/TransactionFactory.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/TransactionFactory.java index 8488a61..e9e7dcf 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/TransactionFactory.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/transaction/TransactionFactory.java @@ -32,13 +32,13 @@ import org.apache.ofbiz.entity.datasource.GenericHelperInfo; */ public interface TransactionFactory { - public TransactionManager getTransactionManager(); + TransactionManager getTransactionManager(); - public UserTransaction getUserTransaction(); + UserTransaction getUserTransaction(); - public String getTxMgrName(); + String getTxMgrName(); - public Connection getConnection(GenericHelperInfo helperInfo) throws SQLException, GenericEntityException; + Connection getConnection(GenericHelperInfo helperInfo) throws SQLException, GenericEntityException; - public void shutdown(); + void shutdown(); } diff --git a/framework/entity/src/main/java/org/apache/ofbiz/entity/util/EntityQuery.java b/framework/entity/src/main/java/org/apache/ofbiz/entity/util/EntityQuery.java index b0c3aa7..167f58c 100644 --- a/framework/entity/src/main/java/org/apache/ofbiz/entity/util/EntityQuery.java +++ b/framework/entity/src/main/java/org/apache/ofbiz/entity/util/EntityQuery.java @@ -128,7 +128,7 @@ public class EntityQuery { * @return this EntityQuery object, to enable chaining */ public EntityQuery from(DynamicViewEntity dynamicViewEntity) { - this.dynamicViewEntity = dynamicViewEntity; + this.dynamicViewEntity = dynamicViewEntity; this.entityName = null; return this; } @@ -313,7 +313,7 @@ public class EntityQuery { * @return this EntityQuery object, to enable chaining */ public EntityQuery filterByDate() { - this.filterByDate = true; + this.filterByDate = true; this.filterByDateMoment = null; this.filterByFieldNames = null; return this; @@ -360,7 +360,7 @@ public class EntityQuery { * @return this EntityQuery object, to enable chaining */ public EntityQuery filterByDate(Timestamp moment, String... filterByFieldName) { - this.filterByDate = true; + this.filterByDate = true; this.filterByDateMoment = moment; if (filterByFieldName.length % 2 != 0) { throw new IllegalArgumentException("You must pass an even sized array to this method, each pair should represent a from date field name and a thru date field name"); diff --git a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataLoadContainer.java b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataLoadContainer.java index e44b4bd..d41a2be 100644 --- a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataLoadContainer.java +++ b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataLoadContainer.java @@ -112,7 +112,7 @@ public class EntityDataLoadContainer implements Container { } } else { // load data for a single delegator - loadDataForDelegator(loadDataProps, configuration, delegatorNameProp, overrideDelegator); + loadDataForDelegator(loadDataProps, configuration, delegatorNameProp, overrideDelegator); } } diff --git a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/eca/EntityEcaCondition.java b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/eca/EntityEcaCondition.java index 7f91cc6..acd2eb1 100644 --- a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/eca/EntityEcaCondition.java +++ b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/eca/EntityEcaCondition.java @@ -58,16 +58,16 @@ public final class EntityEcaCondition implements java.io.Serializable { this.isService = isService; this.conditionService = condition.getAttribute("service-name"); } else { - this.lhsValueName = condition.getAttribute("field-name"); - this.constant = constant; - if (constant) { - this.rhsValueName = condition.getAttribute("value"); - } else { - this.rhsValueName = condition.getAttribute("to-field-name"); - } - this.operator = condition.getAttribute("operator"); - this.compareType = condition.getAttribute("type"); - this.format = condition.getAttribute("format"); + this.lhsValueName = condition.getAttribute("field-name"); + this.constant = constant; + if (constant) { + this.rhsValueName = condition.getAttribute("value"); + } else { + this.rhsValueName = condition.getAttribute("to-field-name"); + } + this.operator = condition.getAttribute("operator"); + this.compareType = condition.getAttribute("type"); + this.format = condition.getAttribute("format"); } } @@ -89,14 +89,14 @@ public final class EntityEcaCondition implements java.io.Serializable { Boolean conditionReply = Boolean.FALSE; if (ServiceUtil.isError(conditionServiceResult)) { - Debug.logError("Error in condition-service : " + - ServiceUtil.getErrorMessage(conditionServiceResult), MODULE); + Debug.logError("Error in condition-service : " + + ServiceUtil.getErrorMessage(conditionServiceResult), MODULE); } else { conditionReply = (Boolean) conditionServiceResult.get("conditionReply"); } return conditionReply; } catch (GenericServiceException gse) { - throw new GenericEntityException("Error in calling condition service "+conditionService+". "+gse.getMessage()); + throw new GenericEntityException("Error in calling condition service " + conditionService+". " + gse.getMessage()); } } @@ -188,7 +188,7 @@ public final class EntityEcaCondition implements java.io.Serializable { protected List<String> getFieldNames() { List<String> fieldNameList = new ArrayList<>(); - if ( UtilValidate.isNotEmpty(lhsValueName) ) { + if (UtilValidate.isNotEmpty(lhsValueName)) { fieldNameList.add(lhsValueName); } if (!constant && UtilValidate.isNotEmpty(rhsValueName)) { diff --git a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/eca/EntityEcaRule.java b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/eca/EntityEcaRule.java index 531093b..3833cc5 100644 --- a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/eca/EntityEcaRule.java +++ b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/eca/EntityEcaRule.java @@ -52,7 +52,7 @@ public final class EntityEcaRule implements java.io.Serializable { private final List<EntityEcaCondition> conditions; private final List<Object> actionsAndSets; private boolean enabled = true; - private final List<String> conditionFieldNames = new ArrayList<>(); + private final List<String> conditionFieldNames = new ArrayList<>(); public EntityEcaRule(Element eca) { this.entityName = eca.getAttribute("entity"); diff --git a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/permission/EntityPermissionChecker.java b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/permission/EntityPermissionChecker.java index 2451aee..061ce39 100644 --- a/framework/entityext/src/main/java/org/apache/ofbiz/entityext/permission/EntityPermissionChecker.java +++ b/framework/entityext/src/main/java/org/apache/ofbiz/entityext/permission/EntityPermissionChecker.java @@ -123,19 +123,20 @@ public class EntityPermissionChecker { if (userLogin != null) { partyId = userLogin.getString("partyId"); } - delegator = (Delegator) request.getAttribute("delegator"); + delegator = (Delegator) request.getAttribute("delegator"); } if (auxiliaryValueGetter != null) auxiliaryValueGetter.clearList(); if (relatedRoleGetter != null) relatedRoleGetter.clearList(); try { permissionConditionGetter.init(delegator); - passed = checkPermissionMethod(delegator, partyId, entityName, entityIdList, auxiliaryValueGetter, relatedRoleGetter, permissionConditionGetter); + passed = checkPermissionMethod(delegator, partyId, entityName, entityIdList, auxiliaryValueGetter, relatedRoleGetter, + permissionConditionGetter); if (!passed && displayFailCond) { - String errMsg = "Permission is denied. \nThese are the conditions of which one must be met:\n" - + permissionConditionGetter.dumpAsText(); - List<Object> errorMessageList = UtilGenerics.cast(context.get("errorMessageList")); - errorMessageList.add(errMsg); + String errMsg = "Permission is denied. \nThese are the conditions of which one must be met:\n" + + permissionConditionGetter.dumpAsText(); + List<Object> errorMessageList = UtilGenerics.cast(context.get("errorMessageList")); + errorMessageList.add(errMsg); } } catch (GenericEntityException e) { throw new RuntimeException(e.getMessage()); @@ -143,39 +144,44 @@ public class EntityPermissionChecker { return passed; } - public static Map<String, Object> checkPermission(GenericValue content, String statusId, GenericValue userLogin, List<String> passedPurposes, List<String> targetOperations, List<String> passedRoles, Delegator delegator, Security security, String entityAction) { - String privilegeEnumId = null; - return checkPermission(content, statusId, userLogin, passedPurposes, targetOperations, passedRoles, delegator, security, entityAction, privilegeEnumId, null); + public static Map<String, Object> checkPermission(GenericValue content, String statusId, GenericValue userLogin, List<String> passedPurposes, + List<String> targetOperations, List<String> passedRoles, Delegator delegator, + Security security, String entityAction) { + String privilegeEnumId = null; + return checkPermission(content, statusId, userLogin, passedPurposes, targetOperations, passedRoles, delegator, security, entityAction, + privilegeEnumId, null); } public static Map<String, Object> checkPermission(GenericValue content, String statusId, - GenericValue userLogin, List<String> passedPurposes, - List<String> targetOperations, List<String> passedRoles, - Delegator delegator, - Security security, String entityAction, - String privilegeEnumId, String quickCheckContentId) { - List<String> statusList = null; - if (statusId != null) { - statusList = StringUtil.split(statusId, "|"); - } - return checkPermission(content, statusList, userLogin, passedPurposes, targetOperations, passedRoles, delegator, security, entityAction, privilegeEnumId, quickCheckContentId); + GenericValue userLogin, List<String> passedPurposes, + List<String> targetOperations, List<String> passedRoles, + Delegator delegator, + Security security, String entityAction, + String privilegeEnumId, String quickCheckContentId) { + List<String> statusList = null; + if (statusId != null) { + statusList = StringUtil.split(statusId, "|"); + } + return checkPermission(content, statusList, userLogin, passedPurposes, targetOperations, passedRoles, delegator, security, entityAction, + privilegeEnumId, quickCheckContentId); } public static Map<String, Object> checkPermission(GenericValue content, List<String> statusList, - GenericValue userLogin, List<String> passedPurposes, - List<String> targetOperations, List<String> passedRoles, - Delegator delegator, - Security security, String entityAction, - String privilegeEnumId) { - return checkPermission(content, statusList, userLogin, passedPurposes, targetOperations, passedRoles, delegator, security, entityAction, privilegeEnumId, null); + GenericValue userLogin, List<String> passedPurposes, + List<String> targetOperations, List<String> passedRoles, + Delegator delegator, + Security security, String entityAction, + String privilegeEnumId) { + return checkPermission(content, statusList, userLogin, passedPurposes, targetOperations, passedRoles, delegator, security, entityAction, + privilegeEnumId, null); } public static Map<String, Object> checkPermission(GenericValue content, List<String> statusList, - GenericValue userLogin, List<String> passedPurposes, - List<String> targetOperations, List<String> passedRoles, - Delegator delegator, - Security security, String entityAction, - String privilegeEnumId, String quickCheckContentId) { + GenericValue userLogin, List<String> passedPurposes, + List<String> targetOperations, List<String> passedRoles, + Delegator delegator, + Security security, String entityAction, + String privilegeEnumId, String quickCheckContentId) { List<Object> entityIds = new LinkedList<>(); if (content != null) entityIds.add(content); @@ -183,7 +189,7 @@ public class EntityPermissionChecker { List<String> quickList = StringUtil.split(quickCheckContentId, "|"); if (UtilValidate.isNotEmpty(quickList)) entityIds.addAll(quickList); } - Map<String, Object> results = new HashMap<>(); + Map<String, Object> results = new HashMap<>(); boolean passed = false; if (userLogin != null && entityAction != null) { passed = security.hasEntityPermission("CONTENTMGR", entityAction, userLogin); @@ -193,7 +199,8 @@ public class EntityPermissionChecker { return results; } try { - boolean check = checkPermissionMethod(delegator, userLogin, targetOperations, "Content", entityIds, passedPurposes, null, privilegeEnumId); + boolean check = checkPermissionMethod(delegator, userLogin, targetOperations, "Content", entityIds, passedPurposes, null, + privilegeEnumId); if (check) { results.put("permissionStatus", "granted"); } else { @@ -321,9 +328,9 @@ public class EntityPermissionChecker { Map<String, List<String>> roles = new HashMap<>(); //List purposeList = null; //List roleList = null; - for (Object id: entityIdList) { - GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, id, entities); - if (entity == null) continue; + for (Object id : entityIdList) { + GenericValue entity = getNextEntity(delegator, entityName, pkFieldName, id, entities); + if (entity == null) continue; String statusId = null; if (hasStatusOp && hasStatusField) { @@ -339,7 +346,7 @@ public class EntityPermissionChecker { if (passed) { break; } - } + } if (passed) { return true; @@ -492,7 +499,7 @@ public class EntityPermissionChecker { return passed; } - public static boolean checkPermissionMethod(Delegator delegator, String partyId, String entityName, List<? extends Object> entityIdList, AuxiliaryValueGetter auxiliaryValueGetter, RelatedRoleGetter relatedRoleGetter, PermissionConditionGetter permissionConditionGetter) throws GenericEntityException { + public static boolean checkPermissionMethod(Delegator delegator, String partyId, String entityName, List<? extends Object> entityIdList, AuxiliaryValueGetter auxiliaryValueGetter, RelatedRoleGetter relatedRoleGetter, PermissionConditionGetter permissionConditionGetter) throws GenericEntityException { permissionConditionGetter.init(delegator); if (Debug.verboseOn()) { @@ -592,7 +599,7 @@ public class EntityPermissionChecker { public static GenericValue getNextEntity(Delegator delegator, String entityName, String pkFieldName, Object obj, Map<String, GenericValue> entities) throws GenericEntityException { GenericValue entity = null; if (obj instanceof String) { - String entityId = (String) obj; + String entityId = (String) obj; if (entities != null) entity = entities.get(entityId); if (entity == null) entity = EntityQuery.use(delegator).from(entityName).where(pkFieldName, entityId).cache(true).queryOne(); @@ -602,12 +609,12 @@ public class EntityPermissionChecker { return entity; } - public static boolean checkHasRoleOperations(String partyId, PermissionConditionGetter permissionConditionGetter, Delegator delegator) { + public static boolean checkHasRoleOperations(String partyId, PermissionConditionGetter permissionConditionGetter, Delegator delegator) { List<String> targetOperations = permissionConditionGetter.getOperationList(); return checkHasRoleOperations(partyId, targetOperations, delegator); } - public static boolean checkHasRoleOperations(String partyId, List<String> targetOperations, Delegator delegator) { + public static boolean checkHasRoleOperations(String partyId, List<String> targetOperations, Delegator delegator) { //if (Debug.infoOn()) Debug.logInfo("targetOperations:" + targetOperations, MODULE); //if (Debug.infoOn()) Debug.logInfo("userLoginId:" + userLoginId, MODULE); if (targetOperations == null) return false; @@ -666,11 +673,13 @@ public class EntityPermissionChecker { for (GenericValue targetOp: targetOperations) { String testRoleTypeId = (String) targetOp.get("roleTypeId"); String testContentPurposeTypeId = null; - if (hasPurposeOp) + if (hasPurposeOp) { testContentPurposeTypeId = (String) targetOp.get(lcEntityName + "PurposeTypeId"); + } String testStatusId = null; - if (hasStatusOp) + if (hasStatusOp) { testStatusId = (String) targetOp.get("statusId"); + } //String testPrivilegeEnumId = null; //if (hasPrivilegeOp) //testPrivilegeEnumId = (String) targetOp.get("privilegeEnumId"); @@ -683,9 +692,8 @@ public class EntityPermissionChecker { if (purposesCond && statusCond && roleCond) { - - isMatch = true; - break; + isMatch = true; + break; } } return isMatch; @@ -704,8 +712,8 @@ public class EntityPermissionChecker { permissionConditionGetter.restart(); List<String> auxiliaryValueList = null; if (auxiliaryValueGetter != null) { - auxiliaryValueGetter.init(delegator, entityId); - auxiliaryValueList = auxiliaryValueGetter.getList(); + auxiliaryValueGetter.init(delegator, entityId); + auxiliaryValueList = auxiliaryValueGetter.getList(); if (Debug.verboseOn()) { Debug.logVerbose(auxiliaryValueGetter.dumpAsText(), MODULE); } @@ -735,9 +743,9 @@ public class EntityPermissionChecker { if (modelEntity.getField("statusId") != null) { targStatusId = entity.getString("statusId"); } - if (Debug.verboseOn()) { - Debug.logVerbose("STATUS:" + targStatusId, MODULE); - } + if (Debug.verboseOn()) { + Debug.logVerbose("STATUS:" + targStatusId, MODULE); + } while (permissionConditionGetter.getNext()) { String roleConditionId = permissionConditionGetter.getRoleValue(); @@ -752,8 +760,8 @@ public class EntityPermissionChecker { if (Debug.verboseOn()) { Debug.logVerbose("MATCHED: role:" + roleConditionId + " status:" + statusConditionId + " aux:" + auxiliaryConditionId, MODULE); } - isMatch = true; - break; + isMatch = true; + break; } } return isMatch; @@ -828,10 +836,12 @@ public class EntityPermissionChecker { String roleTypeId = (String) contentRole.get("roleTypeId"); String targPartyId = (String) contentRole.get("partyId"); if (targPartyId.equals(partyId)) { - if (!roles.contains(roleTypeId)) + if (!roles.contains(roleTypeId)) { roles.add(roleTypeId); - if (roleTypeId.equals("AUTHOR") && !roles.contains("OWNER")) + } + if (roleTypeId.equals("AUTHOR") && !roles.contains("OWNER")) { roles.add("OWNER"); + } } else { // Party may be of "PARTY_GROUP" type, in which case the userLogin may still possess this role GenericValue party = null; String partyTypeId = null; @@ -839,15 +849,16 @@ public class EntityPermissionChecker { party = contentRole.getRelatedOne("Party", false); partyTypeId = (String) party.get("partyTypeId"); if (partyTypeId != null && partyTypeId.equals("PARTY_GROUP")) { - Map<String, Object> map = new HashMap<>(); - - // At some point from/thru date will need to be added - map.put("partyIdFrom", partyId); - map.put("partyIdTo", targPartyId); - if (isGroupMember(map, delegator)) { - if (!roles.contains(roleTypeId)) - roles.add(roleTypeId); - } + Map<String, Object> map = new HashMap<>(); + + // At some point from/thru date will need to be added + map.put("partyIdFrom", partyId); + map.put("partyIdTo", targPartyId); + if (isGroupMember(map, delegator)) { + if (!roles.contains(roleTypeId)) { + roles.add(roleTypeId); + } + } } } catch (GenericEntityException e) { Debug.logError(e, "Error in finding related party. " + e.getMessage(), MODULE); @@ -902,7 +913,7 @@ public class EntityPermissionChecker { return false; } if (partyRelationships.size() > 0) { - isMember = true; + isMember = true; } return isMember; @@ -911,19 +922,19 @@ public class EntityPermissionChecker { public interface PermissionConditionGetter { - public boolean getNext(); - public String getRoleValue(); - public String getOperationValue(); - public String getStatusValue(); - public int getPrivilegeValue() throws GenericEntityException; - public String getAuxiliaryValue(); - public void init(Delegator delegator) throws GenericEntityException; - public void restart(); - public void setOperationList(String operationIdString); - public void setOperationList(List<String> opList); - public List<String> getOperationList(); - public String dumpAsText(); - public void clearList(); + boolean getNext(); + String getRoleValue(); + String getOperationValue(); + String getStatusValue(); + int getPrivilegeValue() throws GenericEntityException; + String getAuxiliaryValue(); + void init(Delegator delegator) throws GenericEntityException; + void restart(); + void setOperationList(String operationIdString); + void setOperationList(List<String> opList); + List<String> getOperationList(); + String dumpAsText(); + void clearList(); } public static class StdPermissionConditionGetter implements PermissionConditionGetter { @@ -949,7 +960,7 @@ public class EntityPermissionChecker { this.entityName = "ContentPurposeOperation"; } - public StdPermissionConditionGetter (String entityName, String operationFieldName, String roleFieldName, String statusFieldName, String auxiliaryFieldName, String privilegeFieldName) { + public StdPermissionConditionGetter(String entityName, String operationFieldName, String roleFieldName, String statusFieldName, String auxiliaryFieldName, String privilegeFieldName) { this.operationFieldName = operationFieldName; this.roleFieldName = roleFieldName; @@ -1064,31 +1075,31 @@ public class EntityPermissionChecker { @Override public String dumpAsText() { - List<String> fieldNames = UtilMisc.toList("roleFieldName", "auxiliaryFieldName", "statusFieldName"); - Map<String, Integer> widths = UtilMisc.toMap("roleFieldName", 24, "auxiliaryFieldName", 24, "statusFieldName", 24); - StringBuilder buf = new StringBuilder(); - Integer wid = null; - - buf.append("Dump for "); - buf.append(this.entityName); - buf.append(" ops:"); - buf.append(StringUtil.join(this.operationList, ",")); - buf.append("\n"); - for (String fld: fieldNames) { - wid = widths.get(fld); - buf.append(fld); - for (int i = 0; i < (wid - fld.length()); i++) buf.append("^"); - buf.append(" "); - } - buf.append("\n"); - for (String fld: fieldNames) { - wid = widths.get(fld); - for (int i = 0; i < wid; i++) buf.append("-"); - buf.append(" "); - } - buf.append("\n"); - if (entityList != null) { - for (GenericValue contentPurposeOperation: this.entityList) { + List<String> fieldNames = UtilMisc.toList("roleFieldName", "auxiliaryFieldName", "statusFieldName"); + Map<String, Integer> widths = UtilMisc.toMap("roleFieldName", 24, "auxiliaryFieldName", 24, "statusFieldName", 24); + StringBuilder buf = new StringBuilder(); + Integer wid = null; + + buf.append("Dump for "); + buf.append(this.entityName); + buf.append(" ops:"); + buf.append(StringUtil.join(this.operationList, ",")); + buf.append("\n"); + for (String fld : fieldNames) { + wid = widths.get(fld); + buf.append(fld); + for (int i = 0; i < (wid - fld.length()); i++) buf.append("^"); + buf.append(" "); + } + buf.append("\n"); + for (String fld : fieldNames) { + wid = widths.get(fld); + for (int i = 0; i < wid; i++) buf.append("-"); + buf.append(" "); + } + buf.append("\n"); + if (entityList != null) { + for (GenericValue contentPurposeOperation : this.entityList) { /* String contentOperationId = contentPurposeOperation.getString(this.operationFieldName); if (UtilValidate.isEmpty(contentOperationId)) { @@ -1100,47 +1111,46 @@ public class EntityPermissionChecker { buf.append(" "); */ - String roleTypeId = contentPurposeOperation.getString(this.roleFieldName); - if (UtilValidate.isEmpty(roleTypeId)) { - roleTypeId = ""; - } - wid = widths.get("roleFieldName"); - buf.append(roleTypeId); - for (int i = 0; i < (wid - roleTypeId.length()); i++) buf.append("^"); - buf.append(" "); - - String auxiliaryFieldValue = contentPurposeOperation.getString(this.auxiliaryFieldName); - if (UtilValidate.isEmpty(auxiliaryFieldValue)) { - auxiliaryFieldValue = ""; - } - wid = widths.get("auxiliaryFieldName"); - buf.append(auxiliaryFieldValue); - for (int i = 0; i < (wid - auxiliaryFieldValue.length()); i++) buf.append("^"); - buf.append(" "); + String roleTypeId = contentPurposeOperation.getString(this.roleFieldName); + if (UtilValidate.isEmpty(roleTypeId)) { + roleTypeId = ""; + } + wid = widths.get("roleFieldName"); + buf.append(roleTypeId); + for (int i = 0; i < (wid - roleTypeId.length()); i++) buf.append("^"); + buf.append(" "); - String statusId = contentPurposeOperation.getString(this.statusFieldName); - if (UtilValidate.isEmpty(statusId)) { - statusId = ""; - } - buf.append(statusId); - /* - wid = (Integer) widths.get("statusFieldName"); - for (int i=0; i < (wid.intValue() - statusId.length()); i++) buf.append(" "); - */ - buf.append(" "); + String auxiliaryFieldValue = contentPurposeOperation.getString(this.auxiliaryFieldName); + if (UtilValidate.isEmpty(auxiliaryFieldValue)) { + auxiliaryFieldValue = ""; + } + wid = widths.get("auxiliaryFieldName"); + buf.append(auxiliaryFieldValue); + for (int i = 0; i < (wid - auxiliaryFieldValue.length()); i++) buf.append("^"); + buf.append(" "); - buf.append("\n"); - } - } - return buf.toString(); + String statusId = contentPurposeOperation.getString(this.statusFieldName); + if (UtilValidate.isEmpty(statusId)) { + statusId = ""; + } + buf.append(statusId); + /* + wid = (Integer) widths.get("statusFieldName"); + for (int i=0; i < (wid.intValue() - statusId.length()); i++) buf.append(" "); + */ + buf.append(" "); + buf.append("\n"); + } + } + return buf.toString(); } } public interface AuxiliaryValueGetter { - public void init(Delegator delegator, String entityId) throws GenericEntityException; - public List<String> getList(); - public void clearList(); - public String dumpAsText(); + void init(Delegator delegator, String entityId) throws GenericEntityException; + List<String> getList(); + void clearList(); + String dumpAsText(); } public static class StdAuxiliaryValueGetter implements AuxiliaryValueGetter { @@ -1150,21 +1160,21 @@ public class EntityPermissionChecker { protected String entityName; protected String entityIdName; - public StdAuxiliaryValueGetter () { + public StdAuxiliaryValueGetter ( ) { this.auxiliaryFieldName = "contentPurposeTypeId"; this.entityName = "ContentPurpose"; this.entityIdName = "contentId"; } - public StdAuxiliaryValueGetter (String entityName, String auxiliaryFieldName, String entityIdName) { + public StdAuxiliaryValueGetter(String entityName, String auxiliaryFieldName, String entityIdName) { this.auxiliaryFieldName = auxiliaryFieldName; this.entityName = entityName; this.entityIdName = entityIdName; } - public StdAuxiliaryValueGetter (Element getterElement) { + public StdAuxiliaryValueGetter(Element getterElement) { this.auxiliaryFieldName = getterElement.getAttribute("auxiliary-field-name"); this.entityName = getterElement.getAttribute("entity-name"); @@ -1202,26 +1212,26 @@ public class EntityPermissionChecker { @Override public String dumpAsText() { - StringBuilder buf = new StringBuilder(); - buf.append("AUXILIARY: "); - if (entityList != null) { - for (String val: entityList) { + StringBuilder buf = new StringBuilder(); + buf.append("AUXILIARY: "); + if (entityList != null) { + for (String val : entityList) { buf.append(val); buf.append(" "); } - } - return buf.toString(); + } + return buf.toString(); } } public interface RelatedRoleGetter { - public void init(Delegator delegator, String entityId, String partyId, GenericValue entity) throws GenericEntityException; - public void initWithAncestors(Delegator delegator, GenericValue entity, String partyId) throws GenericEntityException; - public List<String> getList(); - public void clearList(); - public void setList(List<String> lst); - public String dumpAsText(); - public boolean isOwner(GenericValue entity, String targetPartyId); + void init(Delegator delegator, String entityId, String partyId, GenericValue entity) throws GenericEntityException; + void initWithAncestors(Delegator delegator, GenericValue entity, String partyId) throws GenericEntityException; + List<String> getList(); + void clearList(); + void setList(List<String> lst); + String dumpAsText(); + boolean isOwner(GenericValue entity, String targetPartyId); } public static class StdRelatedRoleGetter implements RelatedRoleGetter { @@ -1234,7 +1244,7 @@ public class EntityPermissionChecker { protected String roleEntityName; protected String ownerEntityFieldName; - public StdRelatedRoleGetter () { + public StdRelatedRoleGetter() { this.roleTypeFieldName = "roleTypeId"; this.partyFieldName = "partyId"; @@ -1244,7 +1254,7 @@ public class EntityPermissionChecker { this.roleEntityIdName = "contentId"; } - public StdRelatedRoleGetter (String entityName, String roleTypeFieldName, String roleEntityIdName, String partyFieldName, String ownerEntityFieldName, String roleEntityName) { + public StdRelatedRoleGetter(String entityName, String roleTypeFieldName, String roleEntityIdName, String partyFieldName, String ownerEntityFieldName, String roleEntityName) { this.roleTypeFieldName = roleTypeFieldName; this.partyFieldName = partyFieldName; @@ -1254,7 +1264,7 @@ public class EntityPermissionChecker { this.roleEntityIdName = roleEntityIdName; } - public StdRelatedRoleGetter (Element getterElement) { + public StdRelatedRoleGetter(Element getterElement) { this.roleTypeFieldName = getterElement.getAttribute("role-type-field-name"); this.partyFieldName = getterElement.getAttribute("party-field-name"); @@ -1283,7 +1293,7 @@ public class EntityPermissionChecker { public void init(Delegator delegator, String entityId, String partyId, GenericValue entity) throws GenericEntityException { List<String> lst = getUserRolesFromList(delegator, UtilMisc.toList(entityId), partyId, this.roleEntityIdName, - this.partyFieldName, this.roleTypeFieldName, this.roleEntityName); + this.partyFieldName, this.roleTypeFieldName, this.roleEntityName); this.roleIdList.addAll(lst); if (isOwner(entity, partyId)) { this.roleIdList.add("OWNER"); @@ -1293,12 +1303,13 @@ public class EntityPermissionChecker { @Override public void initWithAncestors(Delegator delegator, GenericValue entity, String partyId) throws GenericEntityException { - List<String> ownedContentIdList = new LinkedList<>(); - getEntityOwners(delegator, entity, ownedContentIdList, this.entityName, this.ownerEntityFieldName); - if (ownedContentIdList.size() > 0) { - List<String> lst = getUserRolesFromList(delegator, ownedContentIdList, partyId, this.roleEntityIdName, this.partyFieldName, this.roleTypeFieldName, this.roleEntityName); - this.roleIdList.addAll(lst); - } + List<String> ownedContentIdList = new LinkedList<>(); + getEntityOwners(delegator, entity, ownedContentIdList, this.entityName, this.ownerEntityFieldName); + if (ownedContentIdList.size() > 0) { + List<String> lst = getUserRolesFromList(delegator, ownedContentIdList, partyId, this.roleEntityIdName, this.partyFieldName, + this.roleTypeFieldName, this.roleEntityName); + this.roleIdList.addAll(lst); + } } @Override @@ -1334,15 +1345,15 @@ public class EntityPermissionChecker { @Override public String dumpAsText() { - StringBuilder buf = new StringBuilder(); - buf.append("ROLES: "); - if (roleIdList != null) { - for (String val: roleIdList) { + StringBuilder buf = new StringBuilder(); + buf.append("ROLES: "); + if (roleIdList != null) { + for (String val : roleIdList) { buf.append(val); buf.append(" "); } - } - return buf.toString(); + } + return buf.toString(); } } @@ -1365,7 +1376,7 @@ public class EntityPermissionChecker { return distinctList; } - public static void getEntityOwners(Delegator delegator, GenericValue entity, List<String> contentOwnerList, String entityName, String ownerIdFieldName) throws GenericEntityException { + public static void getEntityOwners(Delegator delegator, GenericValue entity, List<String> contentOwnerList, String entityName, String ownerIdFieldName) throws GenericEntityException { String ownerContentId = entity.getString(ownerIdFieldName); if (UtilValidate.isNotEmpty(ownerContentId)) { diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/Iterate.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/Iterate.java index 2070b60..5f16b5c 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/Iterate.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/Iterate.java @@ -68,7 +68,7 @@ public final class Iterate extends MethodOperation { public boolean exec(MethodContext methodContext) throws MiniLangException { if (listFma.isEmpty()) { if (Debug.verboseOn()) { - Debug.logVerbose("Collection not found, doing nothing: " + this, MODULE); + Debug.logVerbose("Collection not found, doing nothing: " + this, MODULE); } return true; } @@ -102,7 +102,7 @@ public final class Iterate extends MethodOperation { Collection<Object> theCollection = UtilGenerics.cast(objList); if (theCollection.size() == 0) { if (Debug.verboseOn()) { - Debug.logVerbose("Collection has zero entries, doing nothing: " + this, MODULE); + Debug.logVerbose("Collection has zero entries, doing nothing: " + this, MODULE); } return true; } @@ -128,7 +128,7 @@ public final class Iterate extends MethodOperation { Iterator<Object> theIterator = UtilGenerics.cast(objList); if (!theIterator.hasNext()) { if (Debug.verboseOn()) { - Debug.logVerbose("Iterator has zero entries, doing nothing: " + this, MODULE); + Debug.logVerbose("Iterator has zero entries, doing nothing: " + this, MODULE); } return true; } diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/IterateMap.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/IterateMap.java index 905c5d2..e5a1a57 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/IterateMap.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/method/envops/IterateMap.java @@ -70,24 +70,24 @@ public final class IterateMap extends MethodOperation { Object oldValue = valueFma.get(methodContext.getEnvMap()); if (oldKey != null) { if (Debug.verboseOn()) { - Debug.logVerbose("In iterate-map the key had a non-null value before entering the loop for the operation: " + this, MODULE); + Debug.logVerbose("In iterate-map the key had a non-null value before entering the loop for the operation: " + this, MODULE); } } if (oldValue != null) { if (Debug.verboseOn()) { - Debug.logVerbose("In iterate-map the value had a non-null value before entering the loop for the operation: " + this, MODULE); + Debug.logVerbose("In iterate-map the value had a non-null value before entering the loop for the operation: " + this, MODULE); } } Map<? extends Object, ? extends Object> theMap = mapFma.get(methodContext.getEnvMap()); if (theMap == null) { if (Debug.verboseOn()) { - Debug.logVerbose("Map not found with name " + mapFma + ", doing nothing: " + this, MODULE); + Debug.logVerbose("Map not found with name " + mapFma + ", doing nothing: " + this, MODULE); } return true; } if (theMap.size() == 0) { if (Debug.verboseOn()) { - Debug.logVerbose("Map with name " + mapFma + " has zero entries, doing nothing: " + this, MODULE); + Debug.logVerbose("Map with name " + mapFma + " has zero entries, doing nothing: " + this, MODULE); } return true; } diff --git a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/test/MiniLangTests.java b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/test/MiniLangTests.java index 5104f86..902ac6f 100644 --- a/framework/minilang/src/main/java/org/apache/ofbiz/minilang/test/MiniLangTests.java +++ b/framework/minilang/src/main/java/org/apache/ofbiz/minilang/test/MiniLangTests.java @@ -74,7 +74,7 @@ public class MiniLangTests extends OFBizTestCase { messages = context.getEnv(methodToTest.getServiceErrorMessageListName()); assertNotNull("<check-errors> error message list", messages); assertTrue("<check-errors> error message text", messages.contains("This should fail")); - // <assert>, <not>, and <if-empty> tests + // <assert>, <not>, and <if-empty> tests methodToTest = createSimpleMethod("<simple-method name=\"testAssert\"><assert><not><if-empty field=\"locale\"/></not></assert><check-errors/></simple-method>"); context = createServiceMethodContext(); result = methodToTest.exec(context); diff --git a/framework/security/src/main/java/org/apache/ofbiz/security/SecurityFactory.java b/framework/security/src/main/java/org/apache/ofbiz/security/SecurityFactory.java index 93064b3..e69ee20 100644 --- a/framework/security/src/main/java/org/apache/ofbiz/security/SecurityFactory.java +++ b/framework/security/src/main/java/org/apache/ofbiz/security/SecurityFactory.java @@ -87,10 +87,10 @@ public final class SecurityFactory { private Delegator delegator = null; - private static final Map<String, Map<String, String>> simpleRoleEntity = UtilMisc.toMap( - "ORDERMGR", UtilMisc.<String, String>toMap("name", "OrderRole", "pkey", "orderId"), - "FACILITY", UtilMisc.<String, String>toMap("name", "FacilityParty", "pkey", "facilityId"), - "MARKETING", UtilMisc.<String, String>toMap("name", "MarketingCampaignRole", "pkey", "marketingCampaignId")); + private static final Map<String, Map<String, String>> SIMPLE_ROLE_ENT = UtilMisc.toMap( + "ORDERMGR", UtilMisc.<String, String>toMap("name", "OrderRole", "pkey", "orderId"), + "FACILITY", UtilMisc.<String, String>toMap("name", "FacilityParty", "pkey", "facilityId"), + "MARKETING", UtilMisc.<String, String>toMap("name", "MarketingCampaignRole", "pkey", "marketingCampaignId")); private OFBizSecurity() { } @@ -222,7 +222,7 @@ public final class SecurityFactory { } String entityName = null; EntityCondition condition = null; - Map<String, String> simpleRoleMap = OFBizSecurity.simpleRoleEntity.get(application); + Map<String, String> simpleRoleMap = OFBizSecurity.SIMPLE_ROLE_ENT.get(application); if (simpleRoleMap != null && roles != null) { entityName = simpleRoleMap.get("name"); String pkey = simpleRoleMap.get("pkey"); diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/GenericRequester.java b/framework/service/src/main/java/org/apache/ofbiz/service/GenericRequester.java index 37e2706..276b0ac 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/GenericRequester.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/GenericRequester.java @@ -30,12 +30,12 @@ public interface GenericRequester extends Serializable { * Receive the result of an asynchronous service call * @param result Map of name, value pairs composing the result */ - public void receiveResult(Map<String, Object> result); + void receiveResult(Map<String, Object> result); /** * Receive an exception (Throwable) from an asynchronous service cell * @param t The Throwable which was received */ - public void receiveThrowable(Throwable t); + void receiveThrowable(Throwable t); } diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/GenericServiceCallback.java b/framework/service/src/main/java/org/apache/ofbiz/service/GenericServiceCallback.java index 954685a..68e9848 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/GenericServiceCallback.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/GenericServiceCallback.java @@ -22,8 +22,8 @@ import java.util.Map; public interface GenericServiceCallback { - public boolean isEnabled(); - public void receiveEvent(Map<String, Object> context); - public void receiveEvent(Map<String, Object> context, Map<String, Object> result); - public void receiveEvent(Map<String, Object> context, Throwable error); + boolean isEnabled(); + void receiveEvent(Map<String, Object> context); + void receiveEvent(Map<String, Object> context, Map<String, Object> result); + void receiveEvent(Map<String, Object> context, Throwable error); } diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/LocalDispatcherFactory.java b/framework/service/src/main/java/org/apache/ofbiz/service/LocalDispatcherFactory.java index 381a174..ffdc255 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/LocalDispatcherFactory.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/LocalDispatcherFactory.java @@ -30,5 +30,5 @@ public interface LocalDispatcherFactory { * @param name * @param delegator */ - public LocalDispatcher createLocalDispatcher(String name, Delegator delegator); + LocalDispatcher createLocalDispatcher(String name, Delegator delegator); } diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/ModelPermission.java b/framework/service/src/main/java/org/apache/ofbiz/service/ModelPermission.java index c0765f5..c617782 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/ModelPermission.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/ModelPermission.java @@ -113,7 +113,7 @@ public class ModelPermission implements Serializable { return false; } if (action == null) { - Debug.logWarning("Null action passed for evaluation", MODULE); + Debug.logWarning("Null action passed for evaluation", MODULE); } return security.hasEntityPermission(nameOrRole, action, userLogin); } diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/ServiceDispatcher.java b/framework/service/src/main/java/org/apache/ofbiz/service/ServiceDispatcher.java index 35a63ea..3367498 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/ServiceDispatcher.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/ServiceDispatcher.java @@ -119,8 +119,7 @@ public final class ServiceDispatcher { origDelegator = DelegatorFactory.getDelegator(this.delegator.getOriginalDelegatorName()); } this.jm = JobManager.getInstance(origDelegator, enableJM); - } - catch (GeneralRuntimeException e) { + } catch (GeneralRuntimeException e) { Debug.logWarning(e.getMessage(), MODULE); } } else { @@ -197,10 +196,10 @@ public final class ServiceDispatcher { localContext.remove(local.getName()); if (localContext.size() == 0) { try { - this.shutdown(); - } catch (GenericServiceException e) { - Debug.logError(e, "Trouble shutting down ServiceDispatcher!", MODULE); - } + this.shutdown(); + } catch (GenericServiceException e) { + Debug.logError(e, "Trouble shutting down ServiceDispatcher!", MODULE); + } } } diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/calendar/TemporalExpressions.java b/framework/service/src/main/java/org/apache/ofbiz/service/calendar/TemporalExpressions.java index 758c54f..5aaea9e 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/calendar/TemporalExpressions.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/calendar/TemporalExpressions.java @@ -93,8 +93,7 @@ public class TemporalExpressions implements Serializable { } try { return this.range.equals(((DateRange) obj).range); - } - catch (ClassCastException e) { + } catch (ClassCastException e) { Debug.logInfo(e.getMessage(), MODULE); } } @@ -207,8 +206,7 @@ public class TemporalExpressions implements Serializable { try { DayInMonth that = (DayInMonth) obj; return this.dayOfWeek == that.dayOfWeek && this.occurrence == that.occurrence; - } - catch (ClassCastException e) { + } catch (ClassCastException e) { Debug.logInfo(e.getMessage(), MODULE); } } @@ -340,8 +338,7 @@ public class TemporalExpressions implements Serializable { try { DayOfMonthRange that = (DayOfMonthRange) obj; return this.start == that.start && this.end == that.end; - } - catch (ClassCastException e) { + } catch (ClassCastException e) { Debug.logInfo(e.getMessage(), MODULE); } } @@ -460,8 +457,7 @@ public class TemporalExpressions implements Serializable { try { DayOfWeekRange that = (DayOfWeekRange) obj; return this.start == that.start && this.end == that.end; - } - catch (ClassCastException e) { + } catch (ClassCastException e) { Debug.logInfo(e.getMessage(), MODULE); } } @@ -597,8 +593,7 @@ public class TemporalExpressions implements Serializable { try { Difference that = (Difference) obj; return this.included.equals(that.included) && this.excluded.equals(that.excluded); - } - catch (ClassCastException e) { + } catch (ClassCastException e) { Debug.logInfo(e.getMessage(), MODULE); } } @@ -713,8 +708,7 @@ public class TemporalExpressions implements Serializable { try { Frequency that = (Frequency) obj; return this.start.equals(that.start) && this.freqType == that.freqType && this.freqCount == that.freqCount; - } - catch (ClassCastException e) { + } catch (ClassCastException e) { Debug.logInfo(e.getMessage(), MODULE); } } @@ -871,8 +865,7 @@ public class TemporalExpressions implements Serializable { try { HourRange that = (HourRange) obj; return this.start == that.start && this.end == that.end; - } - catch (ClassCastException e) { + } catch (ClassCastException e) { Debug.logInfo(e.getMessage(), MODULE); } } @@ -1035,8 +1028,7 @@ public class TemporalExpressions implements Serializable { } try { return this.expressionSet.equals(((Intersection) obj).expressionSet); - } - catch (ClassCastException e) { + } catch (ClassCastException e) { Debug.logInfo(e.getMessage(), MODULE); } } @@ -1159,8 +1151,7 @@ public class TemporalExpressions implements Serializable { try { MinuteRange that = (MinuteRange) obj; return this.start == that.start && this.end == that.end; - } - catch (ClassCastException e) { + } catch (ClassCastException e) { Debug.logInfo(e.getMessage(), MODULE); } } @@ -1316,8 +1307,7 @@ public class TemporalExpressions implements Serializable { try { MonthRange that = (MonthRange) obj; return this.start == that.start && this.end == that.end; - } - catch (ClassCastException e) { + } catch (ClassCastException e) { Debug.logInfo(e.getMessage(), MODULE); } } @@ -1479,8 +1469,7 @@ public class TemporalExpressions implements Serializable { try { Substitution that = (Substitution) obj; return this.included.equals(that.included) && this.excluded.equals(that.excluded) && this.substitute.equals(that.substitute); - } - catch (ClassCastException e) { + } catch (ClassCastException e) { Debug.logInfo(e.getMessage(), MODULE); } } @@ -1596,8 +1585,7 @@ public class TemporalExpressions implements Serializable { } try { return this.expressionSet.equals(((Union) obj).expressionSet); - } - catch (ClassCastException e) { + } catch (ClassCastException e) { Debug.logInfo(e.getMessage(), MODULE); } } diff --git a/framework/service/src/main/java/org/apache/ofbiz/service/engine/XMLRPCClientEngine.java b/framework/service/src/main/java/org/apache/ofbiz/service/engine/XMLRPCClientEngine.java index 8cc7a7a..04b3750 100644 --- a/framework/service/src/main/java/org/apache/ofbiz/service/engine/XMLRPCClientEngine.java +++ b/framework/service/src/main/java/org/apache/ofbiz/service/engine/XMLRPCClientEngine.java @@ -90,7 +90,7 @@ public class XMLRPCClientEngine extends GenericAsyncEngine { String password = null; String keyStoreComponent = null; String keyStoreName = null; - String keyAlias = null; + String keyAlias = null; try { url = ServiceConfigUtil.getEngineParameter(engine, "url"); if (Start.getInstance().getConfig().portOffset != 0) { diff --git a/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupCommandUtil.java b/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupCommandUtil.java index 2e2cca1..fb38e34 100644 --- a/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupCommandUtil.java +++ b/framework/start/src/main/java/org/apache/ofbiz/base/start/StartupCommandUtil.java @@ -194,11 +194,11 @@ public final class StartupCommandUtil { static final void highlightAndPrintErrorMessage(String errorMessage) { System.err.println( - "===============================================================================" - + System.lineSeparator() - + errorMessage - + System.lineSeparator() - + "==============================================================================="); + "===============================================================================" + + System.lineSeparator() + + errorMessage + + System.lineSeparator() + + "==============================================================================="); } private static final Options getOfbizStartupOptions() { diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/JWTManager.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/JWTManager.java index 1d51793..4b5fc6f 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/JWTManager.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/JWTManager.java @@ -282,7 +282,7 @@ public class JWTManager { * @return a JWT token */ public static String createJwt(Delegator delegator, Map<String, String> claims) { - int expirationTime = Integer.parseInt(EntityUtilProperties.getPropertyValue("security", "security.jwt.token.expireTime", "1800", delegator)); + int expirationTime = Integer.parseInt(EntityUtilProperties.getPropertyValue("security", "security.jwt.token.expireTime", "1800", delegator)); return createJwt(delegator, claims, expirationTime); } @@ -307,7 +307,7 @@ public class JWTManager { */ public static String createJwt(Delegator delegator, Map<String, String> claims, String keySalt, int expireTime) { if (expireTime <= 0) { - expireTime = Integer.parseInt(EntityUtilProperties.getPropertyValue("security", "security.jwt.token.expireTime", "1800", delegator)); + expireTime = Integer.parseInt(EntityUtilProperties.getPropertyValue("security", "security.jwt.token.expireTime", "1800", delegator)); } String key = JWTManager.getJWTKey(delegator, keySalt); diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java index 6bdb717..ee66b27 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/LoginWorker.java @@ -555,8 +555,7 @@ public final class LoginWorker { } else { try { userLogin.refresh(); - } - catch (GenericEntityException e) { + } catch (GenericEntityException e) { Debug.logError(e, "Error refreshing userLogin value", MODULE); Map<String, String> messageMap = UtilMisc.toMap("errorMessage", e.getMessage()); String errMsg = UtilProperties.getMessage(RESOURCE, "loginevents.following_error_occurred_during_login", messageMap, UtilHttp.getLocale(request)); diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java index 13a407d..c8d30ea 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java @@ -770,24 +770,25 @@ public class RequestHandler { } renderView(viewName, requestMap.securityExternalView, request, response, null); } else if ("view-last-noparam".equals(nextRequestResponse.type)) { - if (Debug.verboseOn()) { - Debug.logVerbose("[RequestHandler.doRequest]: Response is a view." + showSessionId(request), MODULE); - } - - // check for an override view, only used if "success" = eventReturn - String viewName = (UtilValidate.isNotEmpty(overrideViewUri) && (eventReturn == null || "success".equals(eventReturn))) ? overrideViewUri : nextRequestResponse.value; - - // as a further override, look for the _SAVED and then _HOME and then _LAST session attributes - if (session.getAttribute("_SAVED_VIEW_NAME_") != null) { - viewName = (String) session.getAttribute("_SAVED_VIEW_NAME_"); - } else if (session.getAttribute("_HOME_VIEW_NAME_") != null) { - viewName = (String) session.getAttribute("_HOME_VIEW_NAME_"); - } else if (session.getAttribute("_LAST_VIEW_NAME_") != null) { - viewName = (String) session.getAttribute("_LAST_VIEW_NAME_"); - } else if (UtilValidate.isNotEmpty(nextRequestResponse.value)) { - viewName = nextRequestResponse.value; - } - renderView(viewName, requestMap.securityExternalView, request, response, null); + if (Debug.verboseOn()) { + Debug.logVerbose("[RequestHandler.doRequest]: Response is a view." + showSessionId(request), MODULE); + } + + // check for an override view, only used if "success" = eventReturn + String viewName = (UtilValidate.isNotEmpty(overrideViewUri) && (eventReturn == null || "success".equals(eventReturn))) ? + overrideViewUri : nextRequestResponse.value; + + // as a further override, look for the _SAVED and then _HOME and then _LAST session attributes + if (session.getAttribute("_SAVED_VIEW_NAME_") != null) { + viewName = (String) session.getAttribute("_SAVED_VIEW_NAME_"); + } else if (session.getAttribute("_HOME_VIEW_NAME_") != null) { + viewName = (String) session.getAttribute("_HOME_VIEW_NAME_"); + } else if (session.getAttribute("_LAST_VIEW_NAME_") != null) { + viewName = (String) session.getAttribute("_LAST_VIEW_NAME_"); + } else if (UtilValidate.isNotEmpty(nextRequestResponse.value)) { + viewName = nextRequestResponse.value; + } + renderView(viewName, requestMap.securityExternalView, request, response, null); } else if ("view-home".equals(nextRequestResponse.type)) { if (Debug.verboseOn()) { Debug.logVerbose("[RequestHandler.doRequest]: Response is a view." + showSessionId(request), MODULE); @@ -1045,10 +1046,10 @@ public class RequestHandler { //Cache Headers boolean viewNoCache = viewMap.noCache; if (viewNoCache) { - UtilHttp.setResponseBrowserProxyNoCache(resp); - if (Debug.verboseOn()) { - Debug.logVerbose("Sending no-cache headers for view [" + nextPage + "]", MODULE); - } + UtilHttp.setResponseBrowserProxyNoCache(resp); + if (Debug.verboseOn()) { + Debug.logVerbose("Sending no-cache headers for view [" + nextPage + "]", MODULE); + } } else { resp.setHeader("Cache-Control", "Set-Cookie"); } diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/EventHandler.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/EventHandler.java index c1f5f22..26f8867 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/EventHandler.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/EventHandler.java @@ -39,7 +39,7 @@ public interface EventHandler { * definition files for rendering pages or handler options. * @throws EventHandlerException */ - public void init(ServletContext context) throws EventHandlerException; + void init(ServletContext context) throws EventHandlerException; /** * Invoke the web event @@ -51,5 +51,5 @@ public interface EventHandler { *@return String Result code *@throws EventHandlerException */ - public String invoke(Event event, RequestMap requestMap, HttpServletRequest request, HttpServletResponse response) throws EventHandlerException; + String invoke(Event event, RequestMap requestMap, HttpServletRequest request, HttpServletResponse response) throws EventHandlerException; } diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/RequestBodyMapHandler.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/RequestBodyMapHandler.java index 9140f58..329ccaf 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/RequestBodyMapHandler.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/event/RequestBodyMapHandler.java @@ -30,5 +30,5 @@ public interface RequestBodyMapHandler { * @param request the request with the data in its body * @return an instance of <code>Map<String, Object></code> that represents the data in the request body */ - public Map<String, Object> extractMapFromRequestBody(ServletRequest request) throws IOException; + Map<String, Object> extractMapFromRequestBody(ServletRequest request) throws IOException; } diff --git a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/view/ViewHandler.java b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/view/ViewHandler.java index d5981ef..94100ef 100644 --- a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/view/ViewHandler.java +++ b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/view/ViewHandler.java @@ -31,13 +31,13 @@ public interface ViewHandler { * Sets the name of the view handler as declared in the controller configuration file. * @param name String The name of the view handler as declared in the controller configuration file. */ - public void setName(String name); + void setName(String name); /** * Gets the name of the view handler as declared in the controller configuration file. * @return name String The name of the view handler as declared in the controller configuration file. */ - public String getName(); + String getName(); /** * Initializes the handler. Since handlers use the singleton pattern this method should only be called @@ -47,7 +47,7 @@ public interface ViewHandler { * definition files for rendering pages or handler options. * @throws ViewHandlerException */ - public void init(ServletContext context) throws ViewHandlerException; + void init(ServletContext context) throws ViewHandlerException; /** * Render the page. @@ -59,5 +59,5 @@ public interface ViewHandler { * @param response The HttpServletResponse object to be used to present the page. * @throws ViewHandlerException */ - public void render(String name, String page, String info, String contentType, String encoding, HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException; + void render(String name, String page, String info, String contentType, String encoding, HttpServletRequest request, HttpServletResponse response) throws ViewHandlerException; } diff --git a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java index 505b4c1..387bd00 100644 --- a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java +++ b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/WebToolsServices.java @@ -132,7 +132,7 @@ public class WebToolsServices { // ############################# if (UtilValidate.isNotEmpty(filename)) { try { - url = isUrl?FlexibleLocation.resolveLocation(filename):UtilURL.fromFilename(filename); + url = isUrl ? FlexibleLocation.resolveLocation(filename) : UtilURL.fromFilename(filename); } catch (MalformedURLException mue) { return ServiceUtil.returnError(UtilProperties.getMessage(RESOURCE, "WebtoolsInvalidFileName", UtilMisc.toMap("filename", filename, "errorString", mue.getMessage()), locale)); } catch (Exception exc) { @@ -490,7 +490,7 @@ public class WebToolsServices { long numberWritten = 0; ModelEntity me = delegator.getModelEntity(curEntityName); if (me instanceof ModelViewEntity) { - results.add("["+fileNumber +"] [vvv] " + curEntityName + " skipping view entity"); + results.add("[" + fileNumber +"] [vvv] " + curEntityName + " skipping view entity"); continue; } List<EntityCondition> conds = new LinkedList<>(); @@ -519,15 +519,15 @@ public class WebToolsServices { } while ((value = values.next()) != null); writer.println("</entity-engine-xml>"); } catch (UnsupportedEncodingException | FileNotFoundException e) { - results.add("["+fileNumber +"] [xxx] Error when writing " + curEntityName + ": " + e); + results.add("[" + fileNumber +"] [xxx] Error when writing " + curEntityName + ": " + e); } - results.add("["+fileNumber +"] [" + numberWritten + "] " + curEntityName + " wrote " + numberWritten + " records"); + results.add("[" + fileNumber +"] [" + numberWritten + "] " + curEntityName + " wrote " + numberWritten + " records"); } else { - results.add("["+fileNumber +"] [---] " + curEntityName + " has no records, not writing file"); + results.add("[" + fileNumber +"] [---] " + curEntityName + " has no records, not writing file"); } TransactionUtil.commit(beganTx); } catch (GenericEntityException entityEx) { - results.add("["+fileNumber +"] [xxx] Error when writing " + curEntityName + ": " + entityEx); + results.add("[" + fileNumber +"] [xxx] Error when writing " + curEntityName + ": " + entityEx); continue; } fileNumber++; diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelCondition.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelCondition.java index 706a97c..b59761c 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelCondition.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/AbstractModelCondition.java @@ -613,8 +613,7 @@ public abstract class AbstractModelCondition implements Serializable, ModelCondi Map<String, Object> resp; try { resp = dispatcher.runSync(permService.name, svcCtx, 300, true); - } - catch (GenericServiceException e) { + } catch (GenericServiceException e) { Debug.logError(e, MODULE); return false; } diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/IterateSectionWidget.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/IterateSectionWidget.java index 6dbbbdd..f4ba7ea 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/IterateSectionWidget.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/IterateSectionWidget.java @@ -189,7 +189,7 @@ public class IterateSectionWidget extends ModelScreenWidget { contextMs.put("itemIndex", itemIndex); if (iterateIndex < listSize) { - contextMs.put("iterateId", String.valueOf(entryName+iterateIndex)); + contextMs.put("iterateId", String.valueOf(entryName + iterateIndex)); iterateIndex++; } for (ModelScreenWidget.Section section: this.sectionList) { diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelMenuAction.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelMenuAction.java index 2c489da..cac8390 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelMenuAction.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelMenuAction.java @@ -139,10 +139,10 @@ public abstract class ModelMenuAction { } // If newValue is still empty, use the default value - if (this.defaultExdr != null) { - if (ObjectType.isEmpty(newValue)) { + if (this.defaultExdr != null) { + if (ObjectType.isEmpty(newValue)) { newValue = this.defaultExdr.expandString(context); - } + } } if (UtilValidate.isNotEmpty(this.type)) { @@ -161,24 +161,24 @@ public abstract class ModelMenuAction { } } if (this.toScope != null && "user".equals(this.toScope)) { - String originalName = this.field.getOriginalName(); - String currentWidgetTrail = (String) context.get("_WIDGETTRAIL_"); - String newKey = currentWidgetTrail + "|" + originalName; - HttpSession session = (HttpSession) context.get("session"); - session.setAttribute(newKey, newValue); - if (Debug.verboseOn()) { - Debug.logVerbose("In user setting value for field from [" + this.field.getOriginalName() + "]: " + newValue, MODULE); - } + String originalName = this.field.getOriginalName(); + String currentWidgetTrail = (String) context.get("_WIDGETTRAIL_"); + String newKey = currentWidgetTrail + "|" + originalName; + HttpSession session = (HttpSession) context.get("session"); + session.setAttribute(newKey, newValue); + if (Debug.verboseOn()) { + Debug.logVerbose("In user setting value for field from [" + this.field.getOriginalName() + "]: " + newValue, MODULE); + } } else if (this.toScope != null && "application".equals(this.toScope)) { - String originalName = this.field.getOriginalName(); - String currentWidgetTrail = (String) context.get("_WIDGETTRAIL_"); - String newKey = currentWidgetTrail + "|" + originalName; - ServletContext servletContext = (ServletContext) context.get("application"); - servletContext.setAttribute(newKey, newValue); - if (Debug.verboseOn()) { - Debug.logVerbose("In application setting value for field from [" + this.field.getOriginalName() + "]: " + newValue, MODULE); - } + String originalName = this.field.getOriginalName(); + String currentWidgetTrail = (String) context.get("_WIDGETTRAIL_"); + String newKey = currentWidgetTrail + "|" + originalName; + ServletContext servletContext = (ServletContext) context.get("application"); + servletContext.setAttribute(newKey, newValue); + if (Debug.verboseOn()) { + Debug.logVerbose("In application setting value for field from [" + this.field.getOriginalName() + "]: " + newValue, MODULE); + } } else { if (Debug.verboseOn()) { diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelWidgetCondition.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelWidgetCondition.java index cd86a24..c87c466 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelWidgetCondition.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelWidgetCondition.java @@ -488,8 +488,7 @@ public abstract class ModelWidgetCondition implements Serializable { Map<String, Object> resp; try { resp = dispatcher.runSync(permService.name, svcCtx, 300, true); - } - catch (GenericServiceException e) { + } catch (GenericServiceException e) { Debug.logError(e, MODULE); return false; } diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/portal/PortalPageWorker.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/portal/PortalPageWorker.java index 7f822d8..3feb7ec 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/portal/PortalPageWorker.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/portal/PortalPageWorker.java @@ -116,12 +116,12 @@ public class PortalPageWorker { // Get the PortalPage ensuring that it is either owned by the user or a system page EntityCondition cond = EntityCondition.makeCondition(UtilMisc.toList( - EntityCondition.makeCondition("portalPageId", EntityOperator.EQUALS, portalPageId), - EntityCondition.makeCondition(UtilMisc.toList( - EntityCondition.makeCondition("ownerUserLoginId", EntityOperator.EQUALS, "_NA_"), - EntityCondition.makeCondition("ownerUserLoginId", EntityOperator.EQUALS, userLoginId)), - EntityOperator.OR)), - EntityOperator.AND); + EntityCondition.makeCondition("portalPageId", EntityOperator.EQUALS, portalPageId), + EntityCondition.makeCondition(UtilMisc.toList( + EntityCondition.makeCondition("ownerUserLoginId", EntityOperator.EQUALS, "_NA_"), + EntityCondition.makeCondition("ownerUserLoginId", EntityOperator.EQUALS, userLoginId)), + EntityOperator.OR)), + EntityOperator.AND); List<GenericValue> portalPages = EntityQuery.use(delegator).from("PortalPage").where(cond).queryList(); if (UtilValidate.isNotEmpty(portalPages)) { portalPage = EntityUtil.getFirst(portalPages); diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java index 56fb3d4..ed13ec2 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormRenderer.java @@ -128,7 +128,7 @@ public class FormRenderer { } private static Predicate<ModelFormField> filteringIgnoredFields(Map<String, Object> context, Set<String> alreadyRendered) { - return modelFormField -> { + return modelFormField -> { FieldInfo fieldInfo = modelFormField.getFieldInfo(); // render hidden/ignored field widget diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java index 67f107b..e3c7576 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/FormStringRenderer.java @@ -28,76 +28,76 @@ import org.apache.ofbiz.widget.model.ModelFormField; * Widget Library - Form/Grid renderer. */ public interface FormStringRenderer { - public void renderDisplayField(Appendable writer, Map<String, Object> context, ModelFormField.DisplayField displayField) throws IOException; - public void renderHyperlinkField(Appendable writer, Map<String, Object> context, ModelFormField.HyperlinkField hyperlinkField) throws IOException; - public void renderMenuField(Appendable writer, Map<String, Object> context, ModelFormField.MenuField menuField) throws IOException; - - public void renderTextField(Appendable writer, Map<String, Object> context, ModelFormField.TextField textField) throws IOException; - public void renderTextareaField(Appendable writer, Map<String, Object> context, ModelFormField.TextareaField textareaField) throws IOException; - public void renderDateTimeField(Appendable writer, Map<String, Object> context, ModelFormField.DateTimeField dateTimeField) throws IOException; - - public void renderDropDownField(Appendable writer, Map<String, Object> context, ModelFormField.DropDownField dropDownField) throws IOException; - public void renderCheckField(Appendable writer, Map<String, Object> context, ModelFormField.CheckField checkField) throws IOException; - public void renderRadioField(Appendable writer, Map<String, Object> context, ModelFormField.RadioField radioField) throws IOException; - - public void renderSubmitField(Appendable writer, Map<String, Object> context, ModelFormField.SubmitField submitField) throws IOException; - public void renderResetField(Appendable writer, Map<String, Object> context, ModelFormField.ResetField resetField) throws IOException; - - public void renderHiddenField(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String value) throws IOException; - public void renderHiddenField(Appendable writer, Map<String, Object> context, ModelFormField.HiddenField hiddenField) throws IOException; - public void renderIgnoredField(Appendable writer, Map<String, Object> context, ModelFormField.IgnoredField ignoredField) throws IOException; - - public void renderFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException; - public void renderSingleFormFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException; - - public void renderFormOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderMultiFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - - public void renderFormatListWrapperOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatListWrapperClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - - public void renderFormatHeaderRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatHeaderRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatHeaderOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatHeaderClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatHeaderRowCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, int positionSpan) throws IOException; - public void renderFormatHeaderRowCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField) throws IOException; - - public void renderFormatHeaderRowFormCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatHeaderRowFormCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatHeaderRowFormCellTitleSeparator(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, boolean isLast) throws IOException; - - public void renderFormatItemRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatItemRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatItemRowCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, int positionSpan) throws IOException; - public void renderFormatItemRowCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField) throws IOException; - public void renderFormatItemRowFormCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatItemRowFormCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - - public void renderFormatSingleWrapperOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatSingleWrapperClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - - public void renderFormatFieldRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatFieldRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - public void renderFormatFieldRowTitleCellOpen(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException; - public void renderFormatFieldRowTitleCellClose(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException; - public void renderFormatFieldRowSpacerCell(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException; - public void renderFormatFieldRowWidgetCellOpen(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, int positions, int positionSpan, Integer nextPositionInRow) throws IOException; - public void renderFormatFieldRowWidgetCellClose(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, int positions, int positionSpan, Integer nextPositionInRow) throws IOException; - - public void renderFormatEmptySpace(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; - - public void renderTextFindField(Appendable writer, Map<String, Object> context, ModelFormField.TextFindField textField) throws IOException; - public void renderDateFindField(Appendable writer, Map<String, Object> context, ModelFormField.DateFindField textField) throws IOException; - public void renderRangeFindField(Appendable writer, Map<String, Object> context, ModelFormField.RangeFindField textField) throws IOException; - public void renderLookupField(Appendable writer, Map<String, Object> context, ModelFormField.LookupField textField) throws IOException; - public void renderFileField(Appendable writer, Map<String, Object> context, ModelFormField.FileField textField) throws IOException; - public void renderPasswordField(Appendable writer, Map<String, Object> context, ModelFormField.PasswordField textField) throws IOException; - public void renderImageField(Appendable writer, Map<String, Object> context, ModelFormField.ImageField textField) throws IOException; - public void renderBanner(Appendable writer, Map<String, Object> context, ModelForm.Banner banner) throws IOException; - public void renderContainerFindField(Appendable writer, Map<String, Object> context, ModelFormField.ContainerField containerField) throws IOException; - public void renderFieldGroupOpen(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; - public void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; - public void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + void renderDisplayField(Appendable writer, Map<String, Object> context, ModelFormField.DisplayField displayField) throws IOException; + void renderHyperlinkField(Appendable writer, Map<String, Object> context, ModelFormField.HyperlinkField hyperlinkField) throws IOException; + void renderMenuField(Appendable writer, Map<String, Object> context, ModelFormField.MenuField menuField) throws IOException; + + void renderTextField(Appendable writer, Map<String, Object> context, ModelFormField.TextField textField) throws IOException; + void renderTextareaField(Appendable writer, Map<String, Object> context, ModelFormField.TextareaField textareaField) throws IOException; + void renderDateTimeField(Appendable writer, Map<String, Object> context, ModelFormField.DateTimeField dateTimeField) throws IOException; + + void renderDropDownField(Appendable writer, Map<String, Object> context, ModelFormField.DropDownField dropDownField) throws IOException; + void renderCheckField(Appendable writer, Map<String, Object> context, ModelFormField.CheckField checkField) throws IOException; + void renderRadioField(Appendable writer, Map<String, Object> context, ModelFormField.RadioField radioField) throws IOException; + + void renderSubmitField(Appendable writer, Map<String, Object> context, ModelFormField.SubmitField submitField) throws IOException; + void renderResetField(Appendable writer, Map<String, Object> context, ModelFormField.ResetField resetField) throws IOException; + + void renderHiddenField(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String value) throws IOException; + void renderHiddenField(Appendable writer, Map<String, Object> context, ModelFormField.HiddenField hiddenField) throws IOException; + void renderIgnoredField(Appendable writer, Map<String, Object> context, ModelFormField.IgnoredField ignoredField) throws IOException; + + void renderFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException; + void renderSingleFormFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException; + + void renderFormOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + void renderFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + void renderMultiFormClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + + void renderFormatListWrapperOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + void renderFormatListWrapperClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + + void renderFormatHeaderRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + void renderFormatHeaderRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + void renderFormatHeaderOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + void renderFormatHeaderClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + void renderFormatHeaderRowCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, int positionSpan) throws IOException; + void renderFormatHeaderRowCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField) throws IOException; + + void renderFormatHeaderRowFormCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + void renderFormatHeaderRowFormCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + void renderFormatHeaderRowFormCellTitleSeparator(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, boolean isLast) throws IOException; + + void renderFormatItemRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + void renderFormatItemRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + void renderFormatItemRowCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField, int positionSpan) throws IOException; + void renderFormatItemRowCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm, ModelFormField modelFormField) throws IOException; + void renderFormatItemRowFormCellOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + void renderFormatItemRowFormCellClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + + void renderFormatSingleWrapperOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + void renderFormatSingleWrapperClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + + void renderFormatFieldRowOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + void renderFormatFieldRowClose(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + void renderFormatFieldRowTitleCellOpen(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException; + void renderFormatFieldRowTitleCellClose(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException; + void renderFormatFieldRowSpacerCell(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException; + void renderFormatFieldRowWidgetCellOpen(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, int positions, int positionSpan, Integer nextPositionInRow) throws IOException; + void renderFormatFieldRowWidgetCellClose(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, int positions, int positionSpan, Integer nextPositionInRow) throws IOException; + + void renderFormatEmptySpace(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; + + void renderTextFindField(Appendable writer, Map<String, Object> context, ModelFormField.TextFindField textField) throws IOException; + void renderDateFindField(Appendable writer, Map<String, Object> context, ModelFormField.DateFindField textField) throws IOException; + void renderRangeFindField(Appendable writer, Map<String, Object> context, ModelFormField.RangeFindField textField) throws IOException; + void renderLookupField(Appendable writer, Map<String, Object> context, ModelFormField.LookupField textField) throws IOException; + void renderFileField(Appendable writer, Map<String, Object> context, ModelFormField.FileField textField) throws IOException; + void renderPasswordField(Appendable writer, Map<String, Object> context, ModelFormField.PasswordField textField) throws IOException; + void renderImageField(Appendable writer, Map<String, Object> context, ModelFormField.ImageField textField) throws IOException; + void renderBanner(Appendable writer, Map<String, Object> context, ModelForm.Banner banner) throws IOException; + void renderContainerFindField(Appendable writer, Map<String, Object> context, ModelFormField.ContainerField containerField) throws IOException; + void renderFieldGroupOpen(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; + void renderFieldGroupClose(Appendable writer, Map<String, Object> context, ModelForm.FieldGroup fieldGroup) throws IOException; + void renderEmptyFormDataMessage(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException; } diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/MenuWrapTransform.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/MenuWrapTransform.java index 8cca67e..b6a826b 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/MenuWrapTransform.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/MenuWrapTransform.java @@ -70,7 +70,7 @@ public class MenuWrapTransform implements TemplateTransformModel { private static final String MODULE = MenuWrapTransform.class.getName(); public static final String[] upSaveKeyNames = {"globalNodeTrail"}; - public static final String[] saveKeyNames = {"contentId", "subContentId", "subDataResourceTypeId", "mimeTypeId", "whenMap", "locale", "wrapTemplateId", "encloseWrapText", "nullThruDatesOnly", "renderOnStart", "renderOnClose", "menuDefFile", "menuName", "associatedContentId", "wrapperClassName"}; + public static final String[] saveKeyNames = {"contentId", "subContentId", "subDataResourceTypeId", "mimeTypeId", "whenMap", "locale", "wrapTemplateId", "encloseWrapText", "nullThruDatesOnly", "renderOnStart", "renderOnClose", "menuDefFile", "menuName", "associatedContentId", "wrapperClassName"}; @Override diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/ScreenRenderer.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/ScreenRenderer.java index 5aeb8ed..64d355b 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/ScreenRenderer.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/ScreenRenderer.java @@ -261,7 +261,7 @@ public class ScreenRenderer { context.put("requestAttributes", new HttpRequestHashModel(request, FreeMarkerWorker.getDefaultOfbizWrapper())); TaglibFactory JspTaglibs = new TaglibFactory(servletContext); context.put("JspTaglibs", JspTaglibs); - context.put("requestParameters", UtilHttp.getParameterMap(request)); + context.put("requestParameters", UtilHttp.getParameterMap(request)); ServletContextHashModel ftlServletContext = (ServletContextHashModel) request.getAttribute("ftlServletContext"); context.put("Application", ftlServletContext); diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/TreeStringRenderer.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/TreeStringRenderer.java index a7cd75f..26c099b 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/TreeStringRenderer.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/TreeStringRenderer.java @@ -28,11 +28,11 @@ import org.apache.ofbiz.widget.model.ModelTree; */ public interface TreeStringRenderer { - public void renderNodeBegin(Appendable writer, Map<String, Object> context, ModelTree.ModelNode node, int depth) throws IOException; - public void renderNodeEnd(Appendable writer, Map<String, Object> context, ModelTree.ModelNode node) throws IOException; - public void renderLabel(Appendable writer, Map<String, Object> context, ModelTree.ModelNode.Label label) throws IOException; - public void renderLink(Appendable writer, Map<String, Object> context, ModelTree.ModelNode.Link link) throws IOException; - public void renderImage(Appendable writer, Map<String, Object> context, ModelTree.ModelNode.Image image) throws IOException; - public void renderLastElement(Appendable writer, Map<String, Object> context, ModelTree.ModelNode node) throws IOException; - public ScreenStringRenderer getScreenStringRenderer(Map<String, Object> context); + void renderNodeBegin(Appendable writer, Map<String, Object> context, ModelTree.ModelNode node, int depth) throws IOException; + void renderNodeEnd(Appendable writer, Map<String, Object> context, ModelTree.ModelNode node) throws IOException; + void renderLabel(Appendable writer, Map<String, Object> context, ModelTree.ModelNode.Label label) throws IOException; + void renderLink(Appendable writer, Map<String, Object> context, ModelTree.ModelNode.Link link) throws IOException; + void renderImage(Appendable writer, Map<String, Object> context, ModelTree.ModelNode.Image image) throws IOException; + void renderLastElement(Appendable writer, Map<String, Object> context, ModelTree.ModelNode node) throws IOException; + ScreenStringRenderer getScreenStringRenderer(Map<String, Object> context); } diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlMenuRenderer.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlMenuRenderer.java index 05fea5c..4272553 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlMenuRenderer.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlMenuRenderer.java @@ -319,9 +319,9 @@ public class HtmlMenuRenderer extends HtmlWidgetRenderer implements MenuStringRe userLoginId = userLogin.getString("userLoginId"); } if ((userLoginId == null && userLoginIdAtPermGrant != null) - || (userLoginId != null && userLoginIdAtPermGrant == null) - || ((userLoginId != null && userLoginIdAtPermGrant != null) - && !userLoginId.equals(userLoginIdAtPermGrant))) { + || (userLoginId != null && userLoginIdAtPermGrant == null) + || ((userLoginId != null && userLoginIdAtPermGrant != null) + && !userLoginId.equals(userLoginIdAtPermGrant))) { hasChanged = true; } else { if (userLoginIdAtPermGrant != null) { @@ -421,9 +421,9 @@ public class HtmlMenuRenderer extends HtmlWidgetRenderer implements MenuStringRe writer.append(" href=\""); if ("hidden-form".equals(linkType)) { - writer.append("javascript:document."); - writer.append(uniqueItemName); - writer.append(".submit()"); + writer.append("javascript:document."); + writer.append(uniqueItemName); + writer.append(".submit()"); } else { WidgetWorker.buildHyperlinkUrl(writer, target, link.getUrlMode(), link.getParameterMap(context), link.getPrefix(context), link.getFullPath(), link.getSecure(), link.getEncode(), request, response, context); diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlMenuWrapper.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlMenuWrapper.java index d0926b6..952ebb3 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlMenuWrapper.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlMenuWrapper.java @@ -150,7 +150,7 @@ public class HtmlMenuWrapper { this.context.put(name, value); } - public void putInContext(String menuItemName, String valueName, Object value) { + public void putInContext(String menuItemName, String valueName, Object value) { Object obj = context.get(menuItemName); Map<String, Object> valueMap = (obj instanceof Map) ? UtilGenerics.cast(obj) : null; if (valueMap == null) { diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlMenuWrapperImage.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlMenuWrapperImage.java index 5c23881..a250549 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlMenuWrapperImage.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/html/HtmlMenuWrapperImage.java @@ -62,10 +62,11 @@ public class HtmlMenuWrapperImage extends HtmlMenuWrapper { Delegator delegator = (Delegator) request.getAttribute("delegator"); try { for (ModelMenuItem menuItem : modelMenu.getMenuItemList()) { - String contentId = menuItem.getAssociatedContentId(dummyMap); - GenericValue webSitePublishPoint = EntityQuery.use(delegator).from("WebSitePublishPoint").where("contentId", contentId).cache().queryOne(); - String menuItemName = menuItem.getName(); - putInContext(menuItemName, "WebSitePublishPoint", webSitePublishPoint); + String contentId = menuItem.getAssociatedContentId(dummyMap); + GenericValue webSitePublishPoint = + EntityQuery.use(delegator).from("WebSitePublishPoint").where("contentId", contentId).cache().queryOne(); + String menuItemName = menuItem.getName(); + putInContext(menuItemName, "WebSitePublishPoint", webSitePublishPoint); } } catch (GenericEntityException e) { return; diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java index cc258fd..4e07cb9 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroFormRenderer.java @@ -1440,7 +1440,7 @@ public final class MacroFormRenderer implements FormStringRenderer { String focusFieldName = modelForm.getFocusFieldName(); // Generate CSRF name & value for form - String csrfNameValue = CsrfUtil.getTokenNameNonAjax() + " " +CsrfUtil.generateTokenForNonAjax(request, targ); + String csrfNameValue = CsrfUtil.getTokenNameNonAjax() + " " + CsrfUtil.generateTokenForNonAjax(request, targ); StringWriter sr = new StringWriter(); sr.append("<@renderFormOpen "); diff --git a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenRenderer.java b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenRenderer.java index 9c5f616..5b5f239 100644 --- a/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenRenderer.java +++ b/framework/widget/src/main/java/org/apache/ofbiz/widget/renderer/macro/MacroScreenRenderer.java @@ -376,19 +376,19 @@ public class MacroScreenRenderer implements ScreenStringRenderer { @Override public void renderContentBegin(Appendable writer, Map<String, Object> context, ModelScreenWidget.Content content) throws IOException { - String editRequest = content.getEditRequest(context); - String enableEditName = content.getEnableEditName(context); - String enableEditValue = (String) context.get(enableEditName); + String editRequest = content.getEditRequest(context); + String enableEditName = content.getEnableEditName(context); + String enableEditValue = (String) context.get(enableEditName); - if (Debug.verboseOn()) { + if (Debug.verboseOn()) { Debug.logVerbose("directEditRequest:" + editRequest, MODULE); } - Map<String, Object> parameters = new HashMap<>(); - parameters.put("editRequest", editRequest); - parameters.put("enableEditValue", enableEditValue == null ? "" : enableEditValue); - parameters.put("editContainerStyle", content.getEditContainerStyle(context)); - executeMacro(writer, "renderContentBegin", parameters); + Map<String, Object> parameters = new HashMap<>(); + parameters.put("editRequest", editRequest); + parameters.put("enableEditValue", enableEditValue == null ? "" : enableEditValue); + parameters.put("editContainerStyle", content.getEditContainerStyle(context)); + executeMacro(writer, "renderContentBegin", parameters); } @Override @@ -510,95 +510,97 @@ public class MacroScreenRenderer implements ScreenStringRenderer { @Override public void renderSubContentBegin(Appendable writer, Map<String, Object> context, ModelScreenWidget.SubContent content) throws IOException { - String enableEditName = content.getEnableEditName(context); - String enableEditValue = (String) context.get(enableEditName); - - Map<String, Object> parameters = new HashMap<>(); - parameters.put("editContainerStyle", content.getEditContainerStyle(context)); - parameters.put("editRequest", content.getEditRequest(context)); - parameters.put("enableEditValue", enableEditValue == null ? "" : enableEditValue); - executeMacro(writer, "renderSubContentBegin", parameters); + String enableEditName = content.getEnableEditName(context); + String enableEditValue = (String) context.get(enableEditName); + + Map<String, Object> parameters = new HashMap<>(); + parameters.put("editContainerStyle", content.getEditContainerStyle(context)); + parameters.put("editRequest", content.getEditRequest(context)); + parameters.put("enableEditValue", enableEditValue == null ? "" : enableEditValue); + executeMacro(writer, "renderSubContentBegin", parameters); } @Override public void renderSubContentBody(Appendable writer, Map<String, Object> context, ModelScreenWidget.SubContent content) throws IOException { - Locale locale = UtilMisc.ensureLocale(context.get("locale")); - String mimeTypeId = "text/html"; - String expandedContentId = content.getContentId(context); - String expandedMapKey = content.getMapKey(context); - String renderedContent = ""; - LocalDispatcher dispatcher = (LocalDispatcher) context.get("dispatcher"); - - // create a new map for the content rendering; so our current context does not get overwritten! - Map<String, Object> contentContext = new HashMap<>(); - contentContext.putAll(context); - - try { - if (WidgetContentWorker.getContentWorker() != null) { - renderedContent = WidgetContentWorker.getContentWorker().renderSubContentAsTextExt(dispatcher, expandedContentId, expandedMapKey, contentContext, locale, mimeTypeId, true); - } else { - Debug.logError("Not rendering content, WidgetContentWorker.contentWorker not found.", MODULE); - } - if (UtilValidate.isEmpty(renderedContent)) { - String editRequest = content.getEditRequest(context); - if (UtilValidate.isNotEmpty(editRequest)) { - if (WidgetContentWorker.getContentWorker() != null) { - WidgetContentWorker.getContentWorker().renderContentAsTextExt(dispatcher, "NOCONTENTFOUND", writer, contentContext, locale, mimeTypeId, true); - } else { - Debug.logError("Not rendering content, WidgetContentWorker.contentWorker not found.", MODULE); - } - } - } else { - if (content.xmlEscape()) { - renderedContent = UtilFormatOut.encodeXmlValue(renderedContent); - } - - writer.append(renderedContent); - } - - } catch (GeneralException | IOException e) { - String errMsg = "Error rendering included content with id [" + expandedContentId + "] : " + e.toString(); - Debug.logError(e, errMsg, MODULE); - } + Locale locale = UtilMisc.ensureLocale(context.get("locale")); + String mimeTypeId = "text/html"; + String expandedContentId = content.getContentId(context); + String expandedMapKey = content.getMapKey(context); + String renderedContent = ""; + LocalDispatcher dispatcher = (LocalDispatcher) context.get("dispatcher"); + + // create a new map for the content rendering; so our current context does not get overwritten! + Map<String, Object> contentContext = new HashMap<>(); + contentContext.putAll(context); + + try { + if (WidgetContentWorker.getContentWorker() != null) { + renderedContent = WidgetContentWorker.getContentWorker().renderSubContentAsTextExt(dispatcher, expandedContentId, expandedMapKey, + contentContext, locale, mimeTypeId, true); + } else { + Debug.logError("Not rendering content, WidgetContentWorker.contentWorker not found.", MODULE); + } + if (UtilValidate.isEmpty(renderedContent)) { + String editRequest = content.getEditRequest(context); + if (UtilValidate.isNotEmpty(editRequest)) { + if (WidgetContentWorker.getContentWorker() != null) { + WidgetContentWorker.getContentWorker().renderContentAsTextExt(dispatcher, "NOCONTENTFOUND", writer, contentContext, locale, + mimeTypeId, true); + } else { + Debug.logError("Not rendering content, WidgetContentWorker.contentWorker not found.", MODULE); + } + } + } else { + if (content.xmlEscape()) { + renderedContent = UtilFormatOut.encodeXmlValue(renderedContent); + } + + writer.append(renderedContent); + } + + } catch (GeneralException | IOException e) { + String errMsg = "Error rendering included content with id [" + expandedContentId + "] : " + e.toString(); + Debug.logError(e, errMsg, MODULE); + } } @Override public void renderSubContentEnd(Appendable writer, Map<String, Object> context, ModelScreenWidget.SubContent content) throws IOException { - String editMode = "Edit"; - String editRequest = content.getEditRequest(context); - String enableEditName = content.getEnableEditName(context); - String enableEditValue = (String) context.get(enableEditName); - String expandedContentId = content.getContentId(context); - String expandedMapKey = content.getMapKey(context); - String urlString = ""; + String editMode = "Edit"; + String editRequest = content.getEditRequest(context); + String enableEditName = content.getEnableEditName(context); + String enableEditValue = (String) context.get(enableEditName); + String expandedContentId = content.getContentId(context); + String expandedMapKey = content.getMapKey(context); + String urlString = ""; if (editRequest != null && !(editRequest.toUpperCase(Locale.getDefault()).indexOf("IMAGE") < 1)) { - editMode += " Image"; - } - if (UtilValidate.isNotEmpty(editRequest) && "true".equals(enableEditValue)) { - HttpServletResponse response = (HttpServletResponse) context.get("response"); - HttpServletRequest request = (HttpServletRequest) context.get("request"); - if (request != null && response != null) { + editMode += " Image"; + } + if (UtilValidate.isNotEmpty(editRequest) && "true".equals(enableEditValue)) { + HttpServletResponse response = (HttpServletResponse) context.get("response"); + HttpServletRequest request = (HttpServletRequest) context.get("request"); + if (request != null && response != null) { if (editRequest.indexOf('?') < 0) { editRequest += "?"; } else { editRequest += "&"; } - editRequest += "contentId=" + expandedContentId; - if (UtilValidate.isNotEmpty(expandedMapKey)) { - editRequest += "&mapKey=" + expandedMapKey; - } - RequestHandler rh = RequestHandler.from(request); - urlString = rh.makeLink(request, response, editRequest, false, false, false); - } - } - - Map<String, Object> parameters = new HashMap<>(); - parameters.put("urlString", urlString); - parameters.put("editMode", editMode); - parameters.put("editContainerStyle", content.getEditContainerStyle(context)); - parameters.put("editRequest", editRequest); - parameters.put("enableEditValue", enableEditValue == null ? "" : enableEditValue); - executeMacro(writer, "renderSubContentEnd", parameters); + editRequest += "contentId=" + expandedContentId; + if (UtilValidate.isNotEmpty(expandedMapKey)) { + editRequest += "&mapKey=" + expandedMapKey; + } + RequestHandler rh = RequestHandler.from(request); + urlString = rh.makeLink(request, response, editRequest, false, false, false); + } + } + + Map<String, Object> parameters = new HashMap<>(); + parameters.put("urlString", urlString); + parameters.put("editMode", editMode); + parameters.put("editContainerStyle", content.getEditContainerStyle(context)); + parameters.put("editRequest", editRequest); + parameters.put("enableEditValue", enableEditValue == null ? "" : enableEditValue); + executeMacro(writer, "renderSubContentEnd", parameters); } |
Free forum by Nabble | Edit this page |