Commit Graph
10472 Commits
Author SHA1 Message Date
Mathieu Lirzin 3fb1d50625 Improved: Use method references instead of lambda inside variables
(OFBIZ-10817)

Lambda expressions are not meant to be stored inside variables.  In
most cases it is better to define a static method and use a method
reference instead.  Static methods have the benefits of having a more
explicit signature and some javadoc attached to them.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1864953 13f79535-47bb-0310-9956-ffa450edef68
2019-08-12 09:47:59 +00:00
Jacques Le Roux 7c8f7a55e3 Fixed: [FB] Find Security Bugs
(OFBIZ-9973)

As suggested by Mathieu on dev ML factorises the use of Path::normalize

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1864930 13f79535-47bb-0310-9956-ffa450edef68
2019-08-11 13:23:19 +00:00
Nicolas Malin 4a511be1cc Implemented: Homogenize displaying number with multiple format
(OFBIZ-7532)

To display a number we had different possibilities :
 * on ftl use the template <@ofbizAmount and <@ofbizCurrency
 * by java call a function UtilFormatOut.formatAmount, UtilFormatOut.formatPrice, UtilFormatOut.formatQuantity, etc..
 * by form widget, use <display type=accounting-number for accounting but nothing for other

To simplify and homogenize all, I implemented a number type purpose :
   * default: display a number by default, use when no purpose is present
   * quantity: display a number as a quantity
   * amount: display a number as an amount (like price without currency)
   * spelled: litteral displaying for a number (use on <@ofbizAmount ftl only before)
   * percentage: display a number as a percentage
   * accounting: diplay a number for accounting specific

Each purpose can be associate to a number for displaying it :
   * on ftl <@ofbizNumber number=value format=purpose/>
   * on java UtilFormatOut.formatNumber(value, purpose, delegator, locale)
   * on form widget <display type=number format=purpose/>

The format use by a purpose is define on framework/common/config/number.properties with the template
    .displaying.format = ##0.00

With this, you can surchage a configuration, create your own purpose or surchage only one through entity SystemProperty.

Concerning the backware compatibility: 
 * For the ftl the template <@ofbizAmount is now a link to '<@ofbizNumber format=amount'
 * For java all previous function call UtilFormatOut.formatNumber with the matching purpose
 * For form xml accounting-number is managed as an exection

Last point, display a currency is different that a number, so I didn't refactoring some code for this case (only move properties from general to number for centralize de configuration on the same file)

Thanks Charles Steltzlen to start the refactoring

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1864832 13f79535-47bb-0310-9956-ffa450edef68
2019-08-09 20:37:11 +00:00
Jacques Le Roux 7d5cea96bc Improved: no functional change
Adds missing ASL2 header

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863956 13f79535-47bb-0310-9956-ffa450edef68
2019-07-29 16:50:00 +00:00
Nicolas Malin 46414241e6 Fixed: EntityCondition(EntityOperator, fields...) raise exception with a null value
(OFBIZ-11143)

When you write an entity condition like
  rawProdcuts = from(Product).where(
    EntityCondition.makeCondition(EntityOperator.AND,
       'productTypeId', 'RAW_MATERIAL',
       'quantityUomId', null)
    ).queryList()

the function

  public static EntityFieldMap makeCondition(EntityJoinOperator joinOp, Object... keysValues) 

raise a IllegalArgumentException

The problem came from EntityUtil.makeFields(V... args) (EntityUtil.java:65) who check if a value is an insteance of Comparable and Serializable but didn't take the case tat where have a null value.

Thanks to Pawan Verma for the review

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863685 13f79535-47bb-0310-9956-ffa450edef68
2019-07-24 06:56:44 +00:00
Mathieu Lirzin 7999e3adc1 Improved: Remove useless imports
(OFBIZ-11142)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863507 13f79535-47bb-0310-9956-ffa450edef68
2019-07-20 18:45:21 +00:00
Mathieu Lirzin fc6f9023d2 Improved: Use ‘StandardCharsets.UTF_8’
(OFBIZ-11142)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863505 13f79535-47bb-0310-9956-ffa450edef68
2019-07-20 18:41:37 +00:00
Mathieu Lirzin 2c2340db0a Improved: Use ‘java.util.Base64’
(OFBIZ-11142)

Since Java 8 a standard Base64 encoder/decoder is available. As a
consequence we can remove our embedded implementation and use it
instead.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863504 13f79535-47bb-0310-9956-ffa450edef68
2019-07-20 18:39:57 +00:00
Mathieu Lirzin 54f210a866 Improved: Inline ‘UtilGenerics#checkCollection(Object)’
(OFBIZ-11141)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863502 13f79535-47bb-0310-9956-ffa450edef68
2019-07-20 16:36:12 +00:00
Mathieu Lirzin e9a56a78e5 Improved: Inline ‘UtilGenerics#checkList’
(OFBIZ-11141)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863501 13f79535-47bb-0310-9956-ffa450edef68
2019-07-20 16:35:13 +00:00
Mathieu Lirzin 83fd20607b Improved: Inline ‘UtilGenerics#checkMap’
(OFBIZ-11141)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863500 13f79535-47bb-0310-9956-ffa450edef68
2019-07-20 16:32:34 +00:00
Mathieu Lirzin 17da80d72d Improved: Inline ‘UtilGenerics#checkSet’
(OFBIZ-11141)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863499 13f79535-47bb-0310-9956-ffa450edef68
2019-07-20 16:31:29 +00:00
Mathieu Lirzin 2f12b17663 Improved: Inline ‘UtilGenerics#toList’
(OFBIZ-11141)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863498 13f79535-47bb-0310-9956-ffa450edef68
2019-07-20 16:30:45 +00:00
Mathieu Lirzin 365b044268 Improved: Inline ‘UtilGenerics#toMap’
(OFBIZ-11141)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863497 13f79535-47bb-0310-9956-ffa450edef68
2019-07-20 16:29:52 +00:00
Mathieu Lirzin 7618a51f68 Improved: Rewrite ‘UtilGenerics#toList’ and ‘UtilGenerics#toMap’
(OFBIZ-11141)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863496 13f79535-47bb-0310-9956-ffa450edef68
2019-07-20 16:28:33 +00:00
Mathieu Lirzin 95430bd0cf Improved: Remove useless ‘UtilGenerics#toMap’ overloads
(OFBIZ-11141)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863495 13f79535-47bb-0310-9956-ffa450edef68
2019-07-20 16:27:23 +00:00
Mathieu Lirzin fe9631545e Improved: Rewrite ‘UtilGenerics#checkMap’ to do a simple cast
(OFBIZ-11141)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863494 13f79535-47bb-0310-9956-ffa450edef68
2019-07-20 16:25:51 +00:00
Mathieu Lirzin 7db8f19d08 Improved: Inline ‘UtilGenerics#checkCollectionContainment’
(OFBIZ-11141)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863493 13f79535-47bb-0310-9956-ffa450edef68
2019-07-20 16:24:39 +00:00
Mathieu Lirzin c2e2c3fb15 Improved: Make ‘UtilGenerics#checkCollection(Object, Class)’ more generic
(OFBIZ-11141)

Remove ‘checkList’, ‘checkSet’ and ‘checkStack’ by using
‘checkCollection’ instead.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863489 13f79535-47bb-0310-9956-ffa450edef68
2019-07-20 16:18:23 +00:00
Mathieu Lirzin 1e22cbc6a0 Implememented: Add unit tests for ‘UtilGenerics#checkCollectionCast’
(OFBIZ-11141)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863487 13f79535-47bb-0310-9956-ffa450edef68
2019-07-20 16:10:54 +00:00
Mathieu Lirzin f0dda2a551 Improved: Inline ‘UtilGenerics#checkStack(Object)’
(OFBIZ-11141)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863486 13f79535-47bb-0310-9956-ffa450edef68
2019-07-20 16:09:29 +00:00
Mathieu Lirzin fce71fe4e3 Improved: Inline ‘UtilGenerics#checkCollectionCast’
(OFBIZ-11141)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863485 13f79535-47bb-0310-9956-ffa450edef68
2019-07-20 16:08:21 +00:00
Mathieu Lirzin 7b0053b28c Improved: Remove useless ‘UtilObject#compareToHelper’
(OFBIZ-11140)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863445 13f79535-47bb-0310-9956-ffa450edef68
2019-07-19 22:17:13 +00:00
Mathieu Lirzin 1427c576d5 Improved: Remove useless ‘UtilObject#getBytes’
(OFBIZ-11140)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863444 13f79535-47bb-0310-9956-ffa450edef68
2019-07-19 22:13:43 +00:00
Mathieu Lirzin cc85af1642 Improved: Remove useless ‘UtilObject#equalsHelper’
(OFBIZ-11140)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863443 13f79535-47bb-0310-9956-ffa450edef68
2019-07-19 22:11:39 +00:00
Mathieu Lirzin 6a99c09a18 Improved: Remove ‘UtilMisc#toList’
(OFBIZ-11140)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863442 13f79535-47bb-0310-9956-ffa450edef68
2019-07-19 22:09:52 +00:00
Mathieu Lirzin df8586eccf Improved: Refactor ‘Makeparamlistwithsuffix’
(OFBIZ-11138)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863441 13f79535-47bb-0310-9956-ffa450edef68
2019-07-19 22:08:53 +00:00
Mathieu Lirzin 229fdbb6d5 Implemented: Add unit tests for ‘UtilHttp#makeParamListWithSuffix’
(OFBIZ-11138)

Adapt implementation to facilitate mocking.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863440 13f79535-47bb-0310-9956-ffa450edef68
2019-07-19 22:07:55 +00:00
Mathieu Lirzin 1720a2ff62 Improved: Refactor ‘UtilHttp#makeParamValueFromComposite’
(OFBIZ-11138)

Use ‘LocalDateTime’ instead of ‘Calendar’ and
‘HttpServletRequest#getParameterMap’ instead of
‘HttpServletRequest#getParameterNames’.

The tests and callers has been adapted to remove the ‘locale’ arguments which
made sense only for ‘Calendar’.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863439 13f79535-47bb-0310-9956-ffa450edef68
2019-07-19 22:06:48 +00:00
Mathieu Lirzin 479c16d96b Implemented: Add unit tests for ‘UtilHttp#makeParamValueFromComposite’
(OFBIZ-11138)

The implementation has been adapted to facilitate mocking.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863437 13f79535-47bb-0310-9956-ffa450edef68
2019-07-19 21:50:14 +00:00
Mathieu Lirzin e1d132a6b2 Improved: Use ‘HttpServletRequest#getParameterMap’ when possible
It is better to avoid using obsolete ‘Enumeration’ class when possible
so the calls to ‘HttpServletRequest#getParameterNames’ has been
replaced by ‘HttpServletRequest#getParameterMap’.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863404 13f79535-47bb-0310-9956-ffa450edef68
2019-07-19 14:34:03 +00:00
Mathieu Lirzin 37b6edb2a6 Improved: Remove useless ‘UtilHttp#parametersToAttributes’
(OFBIZ-11138)

This method was so trivial that it doesn't make sense to provide it.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863403 13f79535-47bb-0310-9956-ffa450edef68
2019-07-19 14:32:18 +00:00
Mathieu Lirzin 4c72492d26 Improved: Remove unused ‘UtilHttp#checkURLforSpiders’
(OFBIZ-11138)

It was not used anywhere in the framework or the official plugins.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863402 13f79535-47bb-0310-9956-ffa450edef68
2019-07-19 14:30:57 +00:00
Mathieu Lirzin abf0a9ac4b Improved: Use a predicate in ‘UtilHttp#getParameterMap’
(OFBIZ-11138)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863401 13f79535-47bb-0310-9956-ffa450edef68
2019-07-19 14:29:31 +00:00
Mathieu Lirzin 39ba0a716e Improved: Use a predicate in ‘UtilHttp#getPathInfoOnlyParameterMap’
(OFBIZ-11138)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863400 13f79535-47bb-0310-9956-ffa450edef68
2019-07-19 14:27:23 +00:00
Mathieu Lirzin 54d873a387 Improved: Refactor ‘UtilHttp#getParameterMap’
(OFBIZ-11138)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863398 13f79535-47bb-0310-9956-ffa450edef68
2019-07-19 14:25:35 +00:00
Mathieu Lirzin 1d3d3bee78 Implemented: Add unit tests for ‘UtilHttp#getParameterMap’
(OFBIZ-11138)

Adapt slightly the implementation to make mocking easier.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863397 13f79535-47bb-0310-9956-ffa450edef68
2019-07-19 14:23:51 +00:00
Mathieu Lirzin e576b5e549 Improved: Remove unused ‘UtilHttp#getParameterMap’ overload
(OFBIZ-11138)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863396 13f79535-47bb-0310-9956-ffa450edef68
2019-07-19 14:22:34 +00:00
Mathieu Lirzin caf4fe947d Improved: Refactor ‘UtilHttp#getPathInfoOnlyParameterMap’
(OFBIZ-11138)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863395 13f79535-47bb-0310-9956-ffa450edef68
2019-07-19 14:20:45 +00:00
Mathieu Lirzin b1f0137d19 Implemented: Add unit tests for ‘UtilHttp#getPathInfoOnlyParameterMap’
(OFBIZ-11138)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863394 13f79535-47bb-0310-9956-ffa450edef68
2019-07-19 14:18:40 +00:00
Mathieu Lirzin d972375949 Improved: Inline one ‘UtilHttp#getPathInfoOnlyParameterMap’ overload
(OFBIZ-11138)

‘getPathInfoOnlyParameterMap(HttpServletRequest, Set, Boolean)’ was
used only once and was not adding much to
‘getPathInfoOnlyParameterMap(String, Set, Boolean)’.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863393 13f79535-47bb-0310-9956-ffa450edef68
2019-07-19 14:16:27 +00:00
Mathieu Lirzin aa67827feb Improved: Move ‘AdminServer’ inside a container
(OFBIZ-11136)

‘AdminServer’ provides a portable way to manage life-cycle of the OFBiz
process remotely by allowing administrator to check its running status
or shutting it down.

Previously the ‘AdminServer’ class was a special thread opening a
socket and launched at startup.  However since this class is about
managing some run-time resources with a life-cycle, it matches perfectly
the container abstraction.

A benefit of making ‘AdminServer’ a container is that the startup
process is now simpler and more uniform.

Administrators can now prevent remote shutdown of OFBiz for security
reasons by removing the container declaration.  Additionally They can
delegate the process management job to the init process (PID 0) of the
hosting system like Systemd [1] by replacing this container with
another one.

[1] https://www.freedesktop.org/software/systemd/man/systemd-notify.html


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863024 13f79535-47bb-0310-9956-ffa450edef68
2019-07-13 22:27:04 +00:00
Mathieu Lirzin 978ad322c6 Improved: Pass directly the loaders to ‘loadContainersFromConfigurations’
(OFBIZ-11100)

Since only the loaders are used from the configuration, it is better
to pass those directly as a parameter to the
‘loadContainersFromConfigurations’ method instead of the full
configuration object.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863023 13f79535-47bb-0310-9956-ffa450edef68
2019-07-13 21:42:19 +00:00
Mathieu Lirzin 5a7b0e6947 Improved: Access configurations inside ‘loadContainersFromConfigurations’
(OFBIZ-11100)

This avoids passing an extra argument to
‘loadContainersFromConfigurations’.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863022 13f79535-47bb-0310-9956-ffa450edef68
2019-07-13 21:40:57 +00:00
Mathieu Lirzin a4fe69626b Improved: Inline ‘filterContainersHavingMatchingLoaders’
(OFBIZ-11100)

The filtering of matching loaders is now done directly inside the
‘loadContainersFromConfigurations’ method.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863021 13f79535-47bb-0310-9956-ffa450edef68
2019-07-13 21:40:02 +00:00
Mathieu Lirzin 16ee111ec3 Improved: Deprecate ‘ContainerConfig#getConfiguration(String, String)’
(OFBIZ-11100)

Since there is no global container configuration file anymore this
method should not be used.  It has been superseded by an overload
which do not require to pass the file name of the configuration file.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863020 13f79535-47bb-0310-9956-ffa450edef68
2019-07-13 21:38:51 +00:00
Mathieu Lirzin 72aba3778c Improved: Remove support for “ofbiz-containers.xml”
(OFBIZ-11100)

To extend the containers loaded on startup, it was possible too both
edit the “ofbiz-containers.xml” file or alternatively to define a
container in a component.

This redundancy adds extra complexity in the startup process for no
good extensibility reason. The component container loader is more
flexible since it allows developper to add new containers without
touching the framework so it is better to only rely on this option.

The component loader is now hard-coded directly in code.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863019 13f79535-47bb-0310-9956-ffa450edef68
2019-07-13 21:37:40 +00:00
Mathieu Lirzin 1e73b051b0 Improved: Avoid confusing indirections in ‘StartupControlPanel#start’
(OFBIZ-11137)

The ‘StartupControlPanel#start’ method is delegating its job to
smaller private methods to improve readability.  However the
conditionnals were previously hidden inside those methods with the
unfortunate consequence of making case analysis hard.

To avoid this undesirable effect, the conditionals has been moved
inside the ‘StartupControlPanel#start’ method and some delegate
methods has been inlined when their implementation was trivial.  The
parameters of the remaining delegate methods has be refined to avoid
passing around unneeded things.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1862665 13f79535-47bb-0310-9956-ffa450edef68
2019-07-06 14:39:25 +00:00
Mathieu Lirzin 6925f7961b Improved: Rewrite ‘Start#determineCommandType’
(OFBIZ-11137)

Rename it to ‘Start.CommandType#valueOf’ and use a set to determine
the type of command instead of repetitive stream iterations.

Assuming ‘Set#contains’ is a constant operation, The algorithmic
complexity in worth case has dropped from O(n*m) to O(n+m) where n is
the number of command types and m is the number of startup commands.
In this particular case where n and m are small, the theorical gain
is not significative in term of actual performance.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1862664 13f79535-47bb-0310-9956-ffa450edef68
2019-07-06 14:33:19 +00:00
Mathieu Lirzin e10cf90e09 Improved: Make ‘FormRenderer#getUsedFields’ more generic
(OFBIZ-11135)

We want to be able to reuse the selection of used fields for any form
renderers. As a consequence it seems more appropriate to move the
behavior of ‘FormRenderer#getUsedFields’ to the ‘ModelFormField’
class.

Additionally we have decoupled the filtering logic from the iteration
process by constructing a stateful predicate.

The corresponding unit tests have been adapted to both changes.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1862636 13f79535-47bb-0310-9956-ffa450edef68
2019-07-05 21:58:15 +00:00