This is an automated email from the ASF dual-hosted git repository. danwatford pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/ofbiz-plugins.git
The following commit(s) were added to refs/heads/trunk by this push: new dadcfe077 Improved: Reduce codenarc issues in example plugin (OFBIZ-12789) dadcfe077 is described below commit dadcfe077f769ac70c270446357c841ddbebb4a2 Author: Daniel Watford <dan...@watfordconsulting.com> AuthorDate: Tue Apr 18 14:28:28 2023 +0100 Improved: Reduce codenarc issues in example plugin (OFBIZ-12789) --- example/groovyScripts/ApiTokenGenerator.groovy | 12 ++++++------ example/groovyScripts/LoadReactApp.groovy | 7 +++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/example/groovyScripts/ApiTokenGenerator.groovy b/example/groovyScripts/ApiTokenGenerator.groovy index 484870063..cc4b646ab 100644 --- a/example/groovyScripts/ApiTokenGenerator.groovy +++ b/example/groovyScripts/ApiTokenGenerator.groovy @@ -21,14 +21,14 @@ import org.apache.ofbiz.entity.GenericValue import org.apache.ofbiz.entity.util.EntityUtilProperties import org.apache.ofbiz.webapp.control.JWTManager -GenericValue userLogin = (GenericValue) parameters.userLogin; +GenericValue userLogin = (GenericValue) parameters.userLogin -String expireProperty = "security.jwt.token.expireTime" -String expireTimeString = EntityUtilProperties.getPropertyValue("security", expireProperty, "1800", delegator) -int expireTime = Integer.parseInt(expireTimeString); +String expireProperty = 'security.jwt.token.expireTime' +String expireTimeString = EntityUtilProperties.getPropertyValue('security', expireProperty, '1800', delegator) +int expireTime = Integer.parseInt(expireTimeString) -String jwtToken = JWTManager.createJwt(delegator, [userLoginId: userLogin.getString("userLoginId")], expireTime); +String jwtToken = JWTManager.createJwt(delegator, [userLoginId: userLogin.getString('userLoginId')], expireTime) context.apiToken = [access_token: jwtToken, expires_in : expireTimeString, - token_type : "Bearer"]; + token_type : 'Bearer',] diff --git a/example/groovyScripts/LoadReactApp.groovy b/example/groovyScripts/LoadReactApp.groovy index 8533caabe..21a665c4c 100644 --- a/example/groovyScripts/LoadReactApp.groovy +++ b/example/groovyScripts/LoadReactApp.groovy @@ -1,5 +1,4 @@ import groovy.json.JsonSlurper -import org.apache.ofbiz.widget.model.ScriptLinkHelper import java.nio.file.Path @@ -34,7 +33,7 @@ String contextUrlPath = context.application.context.context.path String contextFilesystemPath = context.contextRoot String reactAppDirectory = 'vite-react-app' -String reactAppUrlPath = contextUrlPath + '/' + reactAppDirectory + '/' +String reactAppUrlPath = "${contextUrlPath}/${reactAppDirectory}/" // Path to the vite react app manifest file. This lists all the files that are part of the react app. // We read this file to identify the main javascript and css files. @@ -56,10 +55,10 @@ String reactAppUrlPath = contextUrlPath + '/' + reactAppDirectory + '/' Path assetManifestPath = Path.of(contextFilesystemPath, reactAppDirectory, 'manifest.json') // Extract the URL paths to the index javascript and css files from the manifest file. -Map<String, Object> assetManifest = new JsonSlurper().parse(assetManifestPath.toFile()) +Object assetManifest = new JsonSlurper().parse(assetManifestPath.toFile()) String stylesheetDistRelativePath = assetManifest.'index.css'.file String javascriptDistRelativePath = assetManifest.'index.html'.file // Return the stylesheet and javascript paths for use by the screen. context.reactAppStylesheetUrlPath = reactAppUrlPath + stylesheetDistRelativePath -context.reactAppJavascriptUrlPath = reactAppUrlPath + javascriptDistRelativePath \ No newline at end of file +context.reactAppJavascriptUrlPath = reactAppUrlPath + javascriptDistRelativePath