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 7aa3db4 Improved: Converted createDownloadContent,updateDownloadContent services from mini-lang to groovy. (OFBIZ-11372)(OFBIZ-11373) Thanks Devanshu Vyas for reporting, Harman Kaur and Rahul for initial patch, Pawan for review. new 0a23151 Merge branch 'trunk' of https://gitbox.apache.org/repos/asf/ofbiz-framework into trunk 7aa3db4 is described below commit 7aa3db4c45f55ab2cb8c471481bb75db7e8f980b Author: Suraj Khurana <[hidden email]> AuthorDate: Mon May 25 13:37:16 2020 +0530 Improved: Converted createDownloadContent,updateDownloadContent services from mini-lang to groovy. (OFBIZ-11372)(OFBIZ-11373) Thanks Devanshu Vyas for reporting, Harman Kaur and Rahul for initial patch, Pawan for review. --- .../groovyScripts/content/ContentServices.groovy | 20 +++++++++++++++++++- .../content/minilang/content/ContentServices.xml | 19 ------------------- applications/content/servicedef/services.xml | 4 ++-- 3 files changed, 21 insertions(+), 22 deletions(-) diff --git a/applications/content/groovyScripts/content/ContentServices.groovy b/applications/content/groovyScripts/content/ContentServices.groovy index fef62e4..c9680dd 100644 --- a/applications/content/groovyScripts/content/ContentServices.groovy +++ b/applications/content/groovyScripts/content/ContentServices.groovy @@ -18,7 +18,7 @@ */ import java.sql.Timestamp - + import org.apache.ofbiz.common.UrlServletHelper import org.apache.ofbiz.entity.condition.EntityCondition import org.apache.ofbiz.entity.condition.EntityOperator @@ -340,4 +340,22 @@ def setContentStatus() { return failure("No Content is not available in the system with content ID - " + parameters.contentId) } return resultMap +} +def createDownloadContent() { + Map serviceResult = success() + result = runService("createOtherDataResource", [dataResourceContent : parameters.file]) + if (ServiceUtil.isError(result)) return result + Map serviceCtx = dispatcher.dispatchContext.makeValidContext("createContent", ModelService.IN_PARAM, parameters) + serviceCtx.dataResourceId = result.dataResourceId + result = runService("createContent", serviceCtx) + if (ServiceUtil.isError(result)) return result + serviceResult.contentId = result.contentId + return serviceResult; +} +def updateDownloadContent() { + Map result = success() + if(parameters.fileDataResourceId) { + result = runService("updateOtherDataResource", [dataResourceId: parameters.fileDataResourceId, dataResourceContent: parameters.file]) + } + return result } \ No newline at end of file diff --git a/applications/content/minilang/content/ContentServices.xml b/applications/content/minilang/content/ContentServices.xml index d920e1d..3ff187f 100644 --- a/applications/content/minilang/content/ContentServices.xml +++ b/applications/content/minilang/content/ContentServices.xml @@ -209,25 +209,6 @@ <field-to-result field="createBodyAssoc.contentId" result-name="contentId"/> </simple-method> - - <simple-method method-name="createDownloadContent" short-description="Create Download as Content"> - <set-service-fields service-name="createContent" map="parameters" to-map="createDownloadContent"/> - <set from-field="parameters.file" field="createDownload.dataResourceContent"/> - <call-service service-name="createOtherDataResource" in-map-name="createDownload"> - <result-to-field result-name="dataResourceId" field="createDownloadContent.dataResourceId"/> - </call-service> - <call-service service-name="createContent" in-map-name="createDownloadContent"> - <result-to-result result-name="contentId"/> - </call-service> - </simple-method> - <simple-method method-name="updateDownloadContent" short-description="Update Download Content"> - <if-not-empty field="parameters.fileDataResourceId"> - <set from-field="parameters.fileDataResourceId" field="updateFile.dataResourceId"/> - <set from-field="parameters.file" field="updateFile.dataResourceContent"/> - <call-service service-name="updateOtherDataResource" in-map-name="updateFile"/> - </if-not-empty> - </simple-method> - <simple-method method-name="createSimpleTextContent" short-description="Create Simple Text Content"> <set-service-fields service-name="createContent" map="parameters" to-map="createSimpleTextContent"/> <set value="DOCUMENT" field="createSimpleTextContent.contentTypeId"/> diff --git a/applications/content/servicedef/services.xml b/applications/content/servicedef/services.xml index 43fede2..71a6b6c 100644 --- a/applications/content/servicedef/services.xml +++ b/applications/content/servicedef/services.xml @@ -143,7 +143,7 @@ <attribute name="htmlBody" type="String" mode="IN" optional="true" allow-html="any"/> </service> - <service name="createDownloadContent" engine="simple" location="component://content/minilang/content/ContentServices.xml" invoke="createDownloadContent"> + <service name="createDownloadContent" engine="simple" location="component://content/groovyScripts/content/ContentServices.groovy" invoke="createDownloadContent"> <permission-service service-name="contentManagerPermission" main-action="CREATE"/> <auto-attributes mode="IN" entity-name="Content" optional="true"/> <attribute name="file" type="String" mode="IN" optional="false"> @@ -153,7 +153,7 @@ </attribute> <override name="contentId" mode="INOUT"/> </service> - <service name="updateDownloadContent" engine="simple" location="component://content/minilang/content/ContentServices.xml" invoke="updateDownloadContent"> + <service name="updateDownloadContent" engine="simple" location="component://content/groovyScripts/content/ContentServices.groovy" invoke="updateDownloadContent"> <permission-service service-name="contentManagerPermission" main-action="UPDATE"/> <attribute name="fileDataResourceId" type="String" mode="IN" optional="true"/> <attribute name="file" type="String" mode="IN" optional="true"/> |
Free forum by Nabble | Edit this page |