Commit Graph
2308 Commits
Author SHA1 Message Date
Samuel Trégouët 000325208a Fixed: Remove dependency management from ‘ComponentContainer’
(OFBIZ-11275)

This fixes a bug identified by ‘testCheckDependencyForComponent’ where
the dependencies declared inside component configurations were not
impacting the component retrieval order.

Component configurations stored in the cache can now be properly
sorted based on their <depends-on> declaration.  The new
‘ComponentConfig#sortDependencies’ method returns a collection of
component configuration following a topological ordering.

In case of dependency cycle we throw an error.
2019-11-25 14:56:18 +01:00
Nicolas Malin 935ffe86ca Fixed: Possible NPE in StringUtil#strToMap
(OFBIZ-11281)

StringUtil#strToMap(String, String, boolean, String) throws Nullpointer for StringUtil.strToMap("", false).

Thanks to Ulrich Heidfeld for this fix
2019-11-14 09:10:05 +01:00
Mathieu Lirzin a521de9ad8 Reverted: "Fixed: Remove dependency management from ‘ComponentContainer’"
(OFBIZ-11275)

This reverts commit 3d3533cf5e.

‘./gradlew cleanAll loadAll’ do not work anymore.
2019-11-09 00:54:56 +01:00
Mathieu Lirzin 03b69b30a5 Fixed: Fix linting issues
(OFBIZ-11265)
2019-11-08 18:19:51 +01:00
Samuel Trégouët 3d3533cf5e Fixed: Remove dependency management from ‘ComponentContainer’
(OFBIZ-11275)

This fixes a bug identified by ‘testCheckDependencyForComponent’ where
the dependencies declared inside component configurations were not
impacting the component retrieval order.

Component configurations stored in the cache can now be properly
sorted based on their <depends-on> declaration.  The new
‘ComponentConfig#sortDependencies’ method returns a collection of
component configuration following a topological ordering.

In case of dependency cycle we throw an error.
2019-11-08 18:19:51 +01:00
Samuel Trégouët 7044af8a6f Implemented: Add a generic directed graph utilitary class
(OFBIZ-11275)
2019-11-08 18:19:51 +01:00
Samuel Trégouët 1317703c9a Implemented: Show dependency resolution algorithm problem
(OFBIZ-11275)

This adds a test demonstrating a bug in the dependency resolution
algorithm done in ‘ComponentContainer’.

When relying on <depends-on> declaration in “ofbiz-component.xml”
files we should expect to retrieve components (and their associated
containers) in a topological ordering meaning a linear ordering where
each component configuration element is placed after its dependencies
configuration elements.  Currently this is not the case and the
dependency declarations only impact the construction of the dynamic
classpath.
2019-11-08 18:19:46 +01:00
Jacques Le Roux 8aea160e04 Fixed: Getting policy error while editing html text data using cms
(OFBIZ-11265)

Service parameter with allow-html="safe" does not check the OWASP sanitizer flag
ie. enabled or not and perform sanitization which causing policy error while
editing text data

getting following exception error:
"In field [textData] by our input policy, your input has not been accepted for
security reason. Please check and modify accordingly, thanks."

Thanks: Pradeep Choudhary for report and suggestion
2019-11-07 15:46:05 +01:00
Mathieu Lirzin 7d9080702d Improved: Turn ‘DependsOnInfo’ into a String
(OFBIZ-11264)

`depends-on` XML tag doesn't have any `loader` or `location` attribute so
DependsOnInfo does not need to extend ResourceInfo.

When removing the class derivation, DependsOnInfo now becomes a simple box
containing a String attribute. In order to make the manipulation of dependency
information simpler, the attribute is now inlined as a simple String value.

Thanks: Samuel Trégouët for your contribution


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1869185 13f79535-47bb-0310-9956-ffa450edef68
2019-10-30 15:47:58 +00:00
Mathieu Lirzin e5592a9bf4 Improved: Add ‘ComponentConfig#toString’ to ease debugging
(OFBIZ-11264)

Thanks: Samuel Trégouët for your contribution


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1869184 13f79535-47bb-0310-9956-ffa450edef68
2019-10-30 15:42:59 +00:00
Mathieu Lirzin 5a8e2dcf3c Improved: Rewrite ‘ComponentContainer#loadComponentsInDirectory’
(OFBIZ-11264)

Use a more declarative style with the stream API.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1869183 13f79535-47bb-0310-9956-ffa450edef68
2019-10-30 15:41:29 +00:00
Mathieu Lirzin aeebf807b8 Improved: Delay the construction of component classpaths
(OFBIZ-11264)

The list of component classpath elements was constructed iteratively
while loading components. This list was additionally used to check if
a component was actually loaded.  This implementation was leading to
hard to understand code that has been replaced by a more appropriate
‘LinkedHashSet’ object.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1869182 13f79535-47bb-0310-9956-ffa450edef68
2019-10-30 15:38:08 +00:00
Mathieu Lirzin 7093974aa7 Improved: Remove unnecessary ‘throws’ declarations
(OFBIZ-11264)

Some declared and/or documented exceptions that were not actually
thrown.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1869181 13f79535-47bb-0310-9956-ffa450edef68
2019-10-30 15:34:30 +00:00
Mathieu Lirzin c9788a0b48 Improved: Import ‘ComponentDef’ and ‘DependsOnInfo’ inner-classes
(OFBIZ-11264)

This allows to use shorter name when using an variable or parameter of
those types.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1869180 13f79535-47bb-0310-9956-ffa450edef68
2019-10-30 15:33:13 +00:00
Mathieu Lirzin 59efa181d2 Improved: Lint unit tests
This makes no behavioral changes, only coding style fixes.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1869037 13f79535-47bb-0310-9956-ffa450edef68
2019-10-27 12:51:08 +00:00
Mathieu Lirzin d5e09638ba Improved: Merge ‘UtilObjectUnitTest’ into ‘UtilObjectTests’
(OFBIZ-11067)

Those classes were testing the same class.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1869023 13f79535-47bb-0310-9956-ffa450edef68
2019-10-26 21:47:46 +00:00
Mathieu Lirzin e5933c677b Improved: Turn ‘UtilObjectTests’ into a unit test class
(OFBIZ-11067)

Adapt ‘UtilObjectUnitTest’ test class to avoid side effects when
testing allowed serialization classes.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1869022 13f79535-47bb-0310-9956-ffa450edef68
2019-10-26 21:46:01 +00:00
Mathieu Lirzin 129ef1e601 Improved: Do not use deprecated ‘Class#newInstance’
(OFBIZ-11262)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1869008 13f79535-47bb-0310-9956-ffa450edef68
2019-10-26 16:20:38 +00:00
Mathieu Lirzin 81be0b893c Improved: Do not use deprecated ‘javax.security.cert.X509Certificate’
(OFBIZ-11262)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1869006 13f79535-47bb-0310-9956-ffa450edef68
2019-10-26 16:16:13 +00:00
Mathieu Lirzin deec38ec43 Improved: Refactor ‘UtilObject#getObjectException’
(OFBIZ-11261)

This moves most of the behavior inside the ‘SafeObjectInputStream’
class which has been refactored too.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1869004 13f79535-47bb-0310-9956-ffa450edef68
2019-10-26 15:17:56 +00:00
Mathieu Lirzin 197d7a515b Fixed: Handle whitelist of serializable classes from properties
(OFBIZ-11261)

There was a bug regarding the way the ‘ListOfSafeObjectsForInputStream’ value
defined in the “SafeObjectInputStream.properties” file was handled.  Mistakenly
only one class identifier was allowed.

Some unit tests have been added to check that the identified bug is fixed.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1869001 13f79535-47bb-0310-9956-ffa450edef68
2019-10-26 14:42:02 +00:00
Mathieu Lirzin de7a855ff5 Fixed: Use ‘ConcurrentHashMap’ to avoid ‘ConcurrentModificationException’
(OFBIZ-11258)

When trying to load components in their dependency order the
‘toBeLoadedComponents’ map is modified while being iterated over which
is not safe for non-concurrent maps.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1868665 13f79535-47bb-0310-9956-ffa450edef68
2019-10-20 16:47:24 +00:00
Mathieu Lirzin 8553f0b5ae Fixed: Fix regression introduced in revision 1867409
(OFBIZ-11192)

‘null’ was an unspecified valid value for the second argument of the
‘ComponentContainer#retrieveComponentConfig’ method.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1868657 13f79535-47bb-0310-9956-ffa450edef68
2019-10-20 16:13:50 +00:00
Mathieu Lirzin 434a0160a2 Improved: Adapt ‘ContainerConfig#getConfigurations’
(OFBIZ-11256)

Remove unused declared ‘ContainerException’ in signature and fix the
javadoc to match the actual specification.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1868630 13f79535-47bb-0310-9956-ffa450edef68
2019-10-19 14:56:50 +00:00
Mathieu Lirzin 29f814cd49 Improved: Mark ‘ContainerConfig#configurations’ as final
(OFBIZ-11256)

Use uppercase to match coding standards.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1868629 13f79535-47bb-0310-9956-ffa450edef68
2019-10-19 14:29:26 +00:00
Mathieu Lirzin 2c686c4655 Improved: Avoid unecessary breakage in ‘ContainerConfig’
(OFBIZ-11256)

This restores ‘public’ modifiers on fields and move the ‘Property’
inner class back to ‘Configuration’ to avoid breakage of client code
extending the ‘Container’ interface.

In order to smooth the transition towards using getters instead of
direct field accesss, the public modifiers on fields are now marked as
deprecated.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1868628 13f79535-47bb-0310-9956-ffa450edef68
2019-10-19 14:27:01 +00:00
Mathieu Lirzin 80c46f9c8c Improved: Add ‘PropertyChildren’ interface
(OFBIZ-11256)

This allows removing some duplicated method overloads.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1868626 13f79535-47bb-0310-9956-ffa450edef68
2019-10-19 14:21:46 +00:00
Mathieu Lirzin 7e7ccba7b3 Improved: Refactor ‘ContainerConfig’ class
(OFBIZ-11256)

This removes some code duplication, make things immutable and add some javadoc.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1868601 13f79535-47bb-0310-9956-ffa450edef68
2019-10-18 19:46:32 +00:00
Jacques Le Roux 6db4ffdbcd Improved: Remove unused methods related to properties in UtilProperties and
EntityUtilProperties
(OFBIZ-11254)

While removing the POS I forgot to remove specific methods I added in 
UtilProperties: setPropertyValue(*,*,*) and setPropertyValueInMemory. 
I finally found that setPropertyValueInMemory is used in one test and so maybe
usefull. setPropertyValue(*,*,*) is unused and can be safemy removed. It's also 
called from EntityUtilProperties so should also be removed there.

This removes it, and also slightly formats 
EntityUtilProperties::setPropertyValueInMemory 


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1868589 13f79535-47bb-0310-9956-ffa450edef68
2019-10-18 11:44:29 +00:00
Nicolas Malin 193280addb Fixed: Down the log level to inform when a property number is empty
When you call a property number undefined, UtilProperty return the default value and you have in console a warning :

    UtilProperties |W| Error converting String  to Integer; using defaultNumber 60.

Or in general if you call and resolve an empty value for a property, they is no reason to inform it as error.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1868580 13f79535-47bb-0310-9956-ffa450edef68
2019-10-18 09:22:11 +00:00
Mathieu Lirzin 13188ab6cc Improved: Refactor ‘ComponentConfig.ClasspathInfo’
(OFBIZ-11192)(OFBIZ-11238)

The validity checks have been moved at construction time instead of
relying on client code to ensure that the class path information are
sound.

A new ‘ComponentConfig.ClasspathInfo.Type’ enum has been defined to
improve type safety.

The location of the class path information is now using a
‘java.nio.file.Path’ class instance.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1868030 13f79535-47bb-0310-9956-ffa450edef68
2019-10-05 16:30:12 +00:00
Mathieu Lirzin f628dec8be Improved: Specify that the component dependencies are never ‘null’
(OFBIZ-11238)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1868029 13f79535-47bb-0310-9956-ffa450edef68
2019-10-05 16:23:21 +00:00
Mathieu Lirzin 60f7041c3d Improved: Use ‘Path’ for component config ‘rootLocation’ attribute
(OFBIZ-11192)

The method ‘ComponentConfig#getRootLocation’ has been removed
and replaced by ‘ComponentConfig#rootLocation’.

The callers have been adapted.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1868028 13f79535-47bb-0310-9956-ffa450edef68
2019-10-05 16:20:32 +00:00
Mathieu Lirzin c982df72c2 Improved: Rewrite ‘Classpath’ class
(OFBIZ-11237)

This class has been moved to ‘org.apache.ofbiz.base.container’ to be
able to reduce its visibility to the “package” level.

The API has been change to avoid unnecessary checks and simpler dataflow.

There was no need to provide thread safety so the ‘synchronized’
blocks have been removed.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1868027 13f79535-47bb-0310-9956-ffa450edef68
2019-10-05 15:44:21 +00:00
Mathieu Lirzin ee77723168 Improved: Remove unnecessary semicolon
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1867986 13f79535-47bb-0310-9956-ffa450edef68
2019-10-04 14:37:45 +00:00
Mathieu Lirzin b37bd7ab79 Improved: Add missing generic types
git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1867984 13f79535-47bb-0310-9956-ffa450edef68
2019-10-04 14:35:07 +00:00
Gil Portenseigne 42c208ee0c Improved: Refactor UelFunctions.java to remove error management via Exception
(OFBIZ-11213)

This refactoring was initiated since using UelFunction::getSize throws 
ClassCastException and log a consequent unneeded stack trace to test 
Object class type. The log is unnecessary, because it is the result of 
each supported class cast trial.

This issue show up that lot of possible NPE were not checked against,
but catched by 'Exception'.

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1867635 13f79535-47bb-0310-9956-ffa450edef68
2019-09-27 13:52:43 +00:00
Mathieu Lirzin 518edddf9c Improved: Refactor ‘ComponentContainer#loadComponentFromConfig’
(OFBIZ-11192)

The unnecessary declared ‘ContainerException’ exception has been removed. A
switch statement has been used and the javadoc has been rewritten.

Additionally the method has been renamed to ‘ComponentContainer#loadComponent’.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1867499 13f79535-47bb-0310-9956-ffa450edef68
2019-09-24 22:23:59 +00:00
Mathieu Lirzin ee95f3bad3 Improved: Use ‘java.nio.file’ API in ‘ComponentContainer’ class
(OFBIZ-11192)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1867409 13f79535-47bb-0310-9956-ffa450edef68
2019-09-23 21:37:57 +00:00
Mathieu Lirzin 6f54d35c91 Improved: Convert ‘Config#ofbizHome’ and ‘Config#logDir’ to a path
(OFBIZ-11192)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1867399 13f79535-47bb-0310-9956-ffa450edef68
2019-09-23 20:04:43 +00:00
Mathieu Lirzin e3acbf6541 Improved: Refactor ‘ComponentLoaderConfig’ class
(OFBIZ-11192)

This redefines the ‘ComponentLoaderConfig#ComponentDef’ class by
removing its unused name attribute.

The ‘java.nio.file’ API has been used to represent the relative path
of a component location.

Various cleanups and Javadoc added.


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1867394 13f79535-47bb-0310-9956-ffa450edef68
2019-09-23 19:38:17 +00:00
Jacques Le Roux cfff42cdc4 Fixed: Fix Default or Empty Catch block in Java and Groovy files
(OFBIZ-8341)

In many Java and Groovy files we have auto generated catch blocks or empty catch 
blocks. 
To avoid such exception swallowing this should be improved to at least log the 
error and also return error in case of service.

Last ones :)

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1866958 13f79535-47bb-0310-9956-ffa450edef68
2019-09-15 07:48:09 +00:00
Jacques Le Roux 28dfdf5c2e Fixed: Fix Default or Empty Catch block in Java and Groovy files
(OFBIZ-8341)

In many Java and Groovy files we have auto generated catch blocks or empty catch 
blocks. 
To avoid such exception swallowing this should be improved to at least log the 
error and also return error in case of service.

Here we use 3 try-with-ressource blocks and log some errors

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1866957 13f79535-47bb-0310-9956-ffa450edef68
2019-09-15 06:32:42 +00:00
Jacques Le Roux 73ebcfb095 Fixed: Fix Default or Empty Catch block in Java and Groovy files
(OFBIZ-8341)

In many Java and Groovy files we have auto generated catch blocks or empty catch 
blocks. 
To avoid such exception swallowing this should be improved to at least log the 
error and also return error in case of service.

Here we use a try-with-ressource block and log some errors

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1866952 13f79535-47bb-0310-9956-ffa450edef68
2019-09-14 17:11:59 +00:00
Jacques Le Roux c7759b0927 Improved: Refactor boolean returns from methods
(OFBIZ-10725)

Stumbled upon it by chance, a last one

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1866931 13f79535-47bb-0310-9956-ffa450edef68
2019-09-14 09:29:06 +00:00
Jacques Le Roux ea17f3f006 Improved: Refactor boolean returns from methods
(OFBIZ-10725)

Reverts mistakes made in previous commit

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1866930 13f79535-47bb-0310-9956-ffa450edef68
2019-09-14 09:25:03 +00:00
Jacques Le Roux 1686f8cb2a Improved: Refactor boolean returns from methods
(OFBIZ-10725)

Stumbled upon it by chance, here are few changes

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1866929 13f79535-47bb-0310-9956-ffa450edef68
2019-09-14 09:19:16 +00:00
Jacques Le Roux 41e3889685 Improved: no functional change
In my previous commit I forgot I used FileUtile::normalizePath (old name 
of now normalizeFilePath) in FileUtile::getFile. This is useless, and reverted
here

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1866927 13f79535-47bb-0310-9956-ffa450edef68
2019-09-14 08:38:13 +00:00
Jacques Le Roux b08e31dda7 Improved: no functional change
While working on OFBIZ-11196,I renamed the normalizePath() method in FileUtil 
class to createFileWithNormalizedPath() and added the normalizeFilePath()
method which deals only with String (in -> out), could be useful later...

git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1866924 13f79535-47bb-0310-9956-ffa450edef68
2019-09-14 08:29:45 +00:00
Jacques Le Roux 48a20b4782 Improved: Improve ObjectInputStream class
(OFBIZ-10837)

Fixes CVE-2019-0189

Allows users to easily override the list of accepted objects by using the
listOfSafeObjectsForInputStream property

CVE-2019-0189


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1866834 13f79535-47bb-0310-9956-ffa450edef68
2019-09-12 07:49:41 +00:00