You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by jl...@apache.org on 2020/05/31 06:52:33 UTC
[ofbiz-framework] 21/28: 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.
This is an automated email from the ASF dual-hosted git repository.
jleroux pushed a commit to branch ecomify-OFBIZ-11468_Convert_ShipmentReceiptServices-squashed
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git
commit 0caf66d514bafd5d3d2eacde2bc68ea439aa7f47
Author: Suraj Khurana <su...@apache.org>
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"/>