Project

General

Profile

bug #8189

Allow configuration of 'user.home' via the spring environment

Added by Andreas Kohlbecker 6 months ago. Updated 21 days ago.

Status:
Closed
Priority:
Highest
Category:
cdmlib
Target version:
Start date:
03/21/2019
Due date:
% Done:

100%

Severity:
blocker
Found in Version:
Tags:

Description

By now it is only possible to configure the ${user.home} via the system properties. That means the only option to set the user.home variable is via the jvm command argument:

-Duser.home=/home/user/

The ${user.home} is crucial since it determines the location of the .cdmLibrary folder.

In end to end integration test (#8187) this is a big caveat since it requires the tests to be run with the correct -Duser.home argument to. Which would be the source of a lot of errors an confusion.

Therefore I suggest to let CdmUtils use the spring environment to determine the ${user.home} variable, this would be fully compatible with the current implementation but would also allow for more flexibility as it is needed in test contexts.


Related issues

Related to Edit - feature request #8187: Use Spring Environment instead of custom code in AbstractWebApplicationConfigurer New 03/20/2019
Related to Edit - task #8505: ConfigFileUtil: turn all spring bean methods into not statical methods. Closed 08/30/2019
Related to Edit - task #2387: make name and location of ~/.cdmlibrary folder configurable New 05/23/2011
Related to Edit - task #8513: CdmUtils: remove MUST_EXIST_FILE and getResourceFolderSeperator() Closed 08/30/2019

Associated revisions

Revision 9b55e525 (diff)
Added by Andreas Kohlbecker 6 months ago

ref #8189 CdmUtils uses the spring environment to find user.home

Revision 44b37b30 (diff)
Added by Andreas Kohlbecker 6 months ago

ref #8189 moving folder funstins from CdmUtils to ConfigFileUtil

Revision a23c2a31 (diff)
Added by Andreas Kohlbecker 6 months ago

ref #8189 moving ConfigFileUtil and AccountStore to cdmlib-persistence:eu.etaxonomy.cdm.config

Revision 110c97a6 (diff)
Added by Andreas Kohlbecker 6 months ago

ref #8189 moving method getFolderSeperator() back to CdmUtils

Revision 0df7271b (diff)
Added by Andreas Kohlbecker 6 months ago

ref #8189 ConfigFileUtil as spring bean in deafult context and tests implemented

Revision 17f913df (diff)
Added by Andreas Kohlbecker 6 months ago

ref #8189 removing unnecessary dependency from cdmlib-commons

Revision cf9ba327 (diff)
Added by Andreas Kohlbecker 6 months ago

ref #8189 cdmlib-remote.properties as not required property source fixes bug introduced in 9b55e525

Revision 55c390a0 (diff)
Added by Andreas Kohlbecker 6 months ago

ref #8189 adapting taxeditor to changes in CdmUtils and ConfigFileUtil

Revision ab611430 (diff)
Added by Andreas Kohlbecker 6 months ago

ref #8189 organizing imports for ConfigFileUtil

Revision 460fe6fd (diff)
Added by Andreas Kohlbecker 6 months ago

ref #8189 DataSourceConfigurer using ConfigFileUtil correctly

Revision eacea571 (diff)
Added by Andreas Kohlbecker 6 months ago

ref #8189 DataSourceConfigurer @Autowiring ConfigFileUtil to init this bean before

Revision 6dd0caa2 (diff)
Added by Andreas Kohlbecker 6 months ago

ref #8189 better reporting of error conditions in AbstractWebApplicationConfigurer

Revision a4b97169 (diff)
Added by Andreas Kohlbecker 6 months ago

ref #8189 cdm-server stores parameters as initParameter instead as Attribute, this allows to access these via Spring Environment

Revision 9b7d57ff (diff)
Added by Andreas Kohlbecker 6 months ago

ref #8189 providing fallback method to retrieve the ~/.cdmLibrary folder without application context

Revision c1460d6c (diff)
Added by Andreas Kohlbecker 6 months ago

ref #8189 removing useless trailing slashes

Revision 4adf618f (diff)
Added by Andreas Kohlbecker 6 months ago

ref #8189 fixing invalid NULL check

Revision 945508b5 (diff)
Added by Andreas Kohlbecker 6 months ago

ref #8189 fallback method for getCdmHomeSubDir() and fixing bug in getCdmHomeDirFallback()

Revision bdc08221 (diff)
Added by Andreas Kohlbecker 6 months ago

ref #8189 using getCdmHomeDirFallback() when the appcontext is not yet available

Revision ee512dbf (diff)
Added by Andreas Kohlbecker 6 months ago

ref #8189 using getCdmHomeDirFallback() when the appcontext is not yet available - 2

Revision c2e4881e (diff)
Added by Katja Luther 6 months ago

changes in CdmServerInfo

Revision 508c257d (diff)
Added by Andreas Kohlbecker 5 months ago

ref #8189 CdmUtils uses the spring environment to find user.home

Revision 03d51e97 (diff)
Added by Andreas Kohlbecker 5 months ago

ref #8189 moving folder funstins from CdmUtils to ConfigFileUtil

Revision 98bb24f8 (diff)
Added by Andreas Kohlbecker 5 months ago

ref #8189 moving ConfigFileUtil and AccountStore to cdmlib-persistence:eu.etaxonomy.cdm.config

Revision 657ed46c (diff)
Added by Andreas Kohlbecker 5 months ago

ref #8189 moving method getFolderSeperator() back to CdmUtils

Revision 69056744 (diff)
Added by Andreas Kohlbecker 5 months ago

ref #8189 ConfigFileUtil as spring bean in deafult context and tests implemented

Revision 6d27d83c (diff)
Added by Andreas Kohlbecker 5 months ago

ref #8189 removing unnecessary dependency from cdmlib-commons

Revision 78e019b6 (diff)
Added by Andreas Kohlbecker 5 months ago

ref #8189 cdmlib-remote.properties as not required property source fixes bug introduced in 9b55e525

Revision e9879222 (diff)
Added by Andreas Kohlbecker 5 months ago

ref #8189 DataSourceConfigurer using ConfigFileUtil correctly

Revision 94aa8075 (diff)
Added by Andreas Kohlbecker 5 months ago

ref #8189 DataSourceConfigurer @Autowiring ConfigFileUtil to init this bean before

Revision e25f9c08 (diff)
Added by Andreas Kohlbecker 5 months ago

ref #8189 better reporting of error conditions in AbstractWebApplicationConfigurer

Revision ebd1ecaf (diff)
Added by Andreas Kohlbecker 5 months ago

ref #8189 providing fallback method to retrieve the ~/.cdmLibrary folder without application context

Revision 06374015 (diff)
Added by Andreas Kohlbecker 5 months ago

ref #8189 removing useless trailing slashes

Revision 9d2efe36 (diff)
Added by Andreas Kohlbecker 5 months ago

ref #8189 fixing invalid NULL check

Revision c98bdf84 (diff)
Added by Andreas Kohlbecker 5 months ago

ref #8189 fallback method for getCdmHomeSubDir() and fixing bug in getCdmHomeDirFallback()

Revision 110bd37f (diff)
Added by Andreas Müller 4 months ago

ref #8189 fix user.home in AccountStore

Revision ce87358e (diff)
Added by Andreas Müller 4 months ago

ref #8189 adapt tests for ConfigFileUtilTest

Revision 768f6835 (diff)
Added by Andreas Kohlbecker 21 days ago

ref #8505 renaming method to getResourceFolderSeperator() and adapting documentation

History

#1 Updated by Andreas Kohlbecker 6 months ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 50

close issue if the changes are not causing any problems.

#2 Updated by Andreas Kohlbecker 6 months ago

  • Related to feature request #8187: Use Spring Environment instead of custom code in AbstractWebApplicationConfigurer added

#3 Updated by Andreas Kohlbecker 6 months ago

  • Status changed from Resolved to In Progress
  • Target version changed from Release 5.6 to Release 5.7

now that the changes made for this ticket are no longer causing any problems I will do the next step: turning all sping bean methods into not statically methods.

#4 Updated by Andreas Müller 4 months ago

  • Status changed from In Progress to Feedback
  • Priority changed from New to Highest
  • Severity changed from normal to blocker

The test ConfigFileUtilTest.testGetFolderSeperator does not work anymore on windows systems when running in maven (not tested other environment)

#5 Updated by Andreas Kohlbecker 4 months ago

  • Assignee changed from Andreas Kohlbecker to Andreas Müller

The test ConfigFileUtilTest.testGetFolderSeperator does not work anymore on windows systems when running in maven

Can you provide me the error message, stacktrace related to this failure?

The Method CdmUtils.getFolderSeperator() is completely redundant since File.separator is extected to provide the same Character. Why are we having an own implementation for somting that java core does for us?

Assert.assertEquals(File.separator, CdmUtils.getFolderSeperator());

Therefore I suggest removing that method as well as the CdmUtils.MUST_EXIST_FILEand the according file in the resources folder.

#6 Updated by Andreas Müller 4 months ago

Andreas Kohlbecker wrote:

The test ConfigFileUtilTest.testGetFolderSeperator does not work anymore on windows systems when running in maven

Can you provide me the error message, stacktrace related to this failure?

Here it is:

Tests run: 3, Failures: 1, Errors: 0, Skipped: 1, Time elapsed: 0.13 sec <<< FAILURE!
testGetFolderSeperator(eu.etaxonomy.cdm.config.ConfigFileUtilTest)  Time elapsed: 0.06 sec  <<< FAILURE!
org.junit.ComparisonFailure: expected:<[\]> but was:<[/]>
    at org.junit.Assert.assertEquals(Assert.java:115)
    at org.junit.Assert.assertEquals(Assert.java:144)
    at eu.etaxonomy.cdm.config.ConfigFileUtilTest.testGetFolderSeperator(ConfigFileUtilTest.java:26)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)

#7 Updated by Andreas Müller 4 months ago

  • Assignee changed from Andreas Müller to Andreas Kohlbecker

Andreas Kohlbecker wrote:

The Method CdmUtils.getFolderSeperator() is completely redundant since File.separator is extected to provide the same Character. Why are we having an own implementation for somting that java core does for us?

I can't see why it should be redundant. CdmUtils.getFolderSeperator differentiates if the code runs from a jar bundle or if it runs from commandline. In the later case the first case you always need "/" as separator while in the later case it is OS dependendend and therefore the test fails.
Distinguishing this is e.g. important when term loading from csv files to distinguish the position of the csv files in the file system. If compiled to a jar you need another folder separator then reading from the ordinary folder on Windows because on Windows File.separator <> "/".

But I agree that we should maybe rename CdmUtils.getFolderSeperator to make clear that it is only for this specific usecase and it is not a general shortcut to replace File.separator

#8 Updated by Andreas Müller 4 months ago

Therefore I do not agree to remove the method or to remove the MUST_EXIST_FILE (but we may remove if there is a better mechanism for this)

#9 Updated by Andreas Müller 4 months ago

Andreas Kohlbecker wrote:

now that the changes made for this ticket are no longer causing any problems I will do the next step: turning all sping bean methods into not statically methods.

Is this already done?

#10 Updated by Andreas Kohlbecker 4 months ago

Andreas Müller wrote:

Andreas Kohlbecker wrote:

now that the changes made for this ticket are no longer causing any problems I will do the next step: turning all sping bean methods into not statically methods.

Is this already done?

Not yet!

#11 Updated by Andreas Kohlbecker 25 days ago

  • Related to task #8505: ConfigFileUtil: turn all spring bean methods into not statical methods. added

#12 Updated by Andreas Kohlbecker 25 days ago

  • Status changed from Feedback to Closed
  • % Done changed from 50 to 100

all remaining tasks copied to #8505

and closing this ticket

#13 Updated by Andreas Kohlbecker 25 days ago

  • Related to task #2387: make name and location of ~/.cdmlibrary folder configurable added

#14 Updated by Andreas Müller 25 days ago

Andreas Müller wrote:

The test ConfigFileUtilTest.testGetFolderSeperator does not work anymore on windows systems when running in maven (not tested other environment)

By the way, I set the test to ignore (or completely deleted it, don't remember) as it didn't make any sense to me

#15 Updated by Andreas Kohlbecker 21 days ago

  • Related to task #8513: CdmUtils: remove MUST_EXIST_FILE and getResourceFolderSeperator() added

#16 Updated by Andreas Kohlbecker 21 days ago

Andreas Müller wrote:

Andreas Müller wrote:

The test ConfigFileUtilTest.testGetFolderSeperator does not work anymore on windows systems when running in maven (not tested other environment)

By the way, I set the test to ignore (or completely deleted it, don't remember) as it didn't make any sense to me

I removed this test as well as the getFolderSeperator() method and the MUST_EXIST_FILE, see #8513 for details.

Also available in: Atom PDF

Add picture from clipboard (Maximum size: 40 MB)