This is an automated email from the ASF dual-hosted git repository.
pawan 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 904491e Improved: Convert indexContentKeywords and
forceIndexContentKeywords services from miniland to
groovy(OFBIZ-11390)(OFBIZ-11392)
904491e is described below
commit 904491ede19c96ad04549d0145d5dc30720c8c0d
Author: Pawan Verma <[email protected]>
AuthorDate: Sat Jul 18 22:11:32 2020 +0530
Improved: Convert indexContentKeywords and forceIndexContentKeywords
services from miniland to groovy(OFBIZ-11390)(OFBIZ-11392)
Thanks, Devanshu for report and Sourabh and Aishwary for the patch.
---
.../groovyScripts/content/ContentServices.groovy | 19 +++++++++++++++++++
.../content/minilang/content/ContentServices.xml | 21 ---------------------
.../content/servicedef/services_content.xml | 8 ++++----
3 files changed, 23 insertions(+), 25 deletions(-)
diff --git a/applications/content/groovyScripts/content/ContentServices.groovy
b/applications/content/groovyScripts/content/ContentServices.groovy
index c4991ae..ed39c78 100644
--- a/applications/content/groovyScripts/content/ContentServices.groovy
+++ b/applications/content/groovyScripts/content/ContentServices.groovy
@@ -19,6 +19,7 @@
import java.sql.Timestamp
+import org.apache.ofbiz.content.content.ContentKeywordIndex
import org.apache.ofbiz.common.UrlServletHelper
import org.apache.ofbiz.entity.condition.EntityCondition
import org.apache.ofbiz.entity.condition.EntityOperator
@@ -438,3 +439,21 @@ def updateCommContentDataResource() {
caSequenceNum : serviceResult.caSequenceNum,
roleTypeList : serviceResult.roleTypeList]
}
+
+def indexContentKeywords() {
+ // this service is meant to be called from an entity ECA for entities that
include a contentId
+ // if it is the Content entity itself triggering this action, then a
[contentInstance] parameter
+ // will be passed and we can save a few cycles looking that up
+ contentInstance = parameters.contentInstance
+ if (!contentInstance) {
+ contentInstance = from("Content").where("contentId",
parameters.contentId).queryOne()
+ }
+ ContentKeywordIndex.indexKeywords(contentInstance)
+ return success()
+}
+
+def forceIndexContentKeywords() {
+ content = from("Content").where("contentId",
parameters.contentId).queryOne()
+ ContentKeywordIndex.forceIndexKeywords(content)
+ return success()
+}
diff --git a/applications/content/minilang/content/ContentServices.xml
b/applications/content/minilang/content/ContentServices.xml
index 0ea5217..285e6ad 100644
--- a/applications/content/minilang/content/ContentServices.xml
+++ b/applications/content/minilang/content/ContentServices.xml
@@ -326,27 +326,6 @@
<set-service-fields service-name="getContentAndDataResource"
map="parameters" to-map="getC"/>
<call-service service-name="getContentAndDataResource"
in-map-name="getC"/>
</simple-method>
- <simple-method method-name="forceIndexContentKeywords"
short-description="induce all the keywords of a content">
- <entity-one entity-name="Content" value-field="content"/>
- <call-class-method
class-name="org.apache.ofbiz.content.content.ContentKeywordIndex"
method-name="forceIndexKeywords">
- <field field="content"
type="org.apache.ofbiz.entity.GenericValue"/>
- </call-class-method>
- </simple-method>
- <simple-method method-name="indexContentKeywords" short-description="Index
the Keywords for a Content" login-required="false">
- <!-- this service is meant to be called from an entity ECA for
entities that include a contentId -->
- <!-- if it is the Content entity itself triggering this action, then a
[contentInstance] parameter
- will be passed and we can save a few cycles looking that up -->
- <set from-field="parameters.contentInstance" field="contentInstance"/>
- <if-empty field="contentInstance">
- <set from-field="parameters.contentId"
field="findContentMap.contentId"/>
- <find-by-primary-key entity-name="Content" map="findContentMap"
value-field="contentInstance"/>
- </if-empty>
-
- <!-- induce keywords-->
- <call-class-method
class-name="org.apache.ofbiz.content.content.ContentKeywordIndex"
method-name="indexKeywords">
- <field field="contentInstance"
type="org.apache.ofbiz.entity.GenericValue"/>
- </call-class-method>
- </simple-method>
<simple-method method-name="createMissingContentAltUrls"
short-description="create missing content alternative urls.">
<now-timestamp field="now"/>
diff --git a/applications/content/servicedef/services_content.xml
b/applications/content/servicedef/services_content.xml
index a1db32f..6f12c3b 100644
--- a/applications/content/servicedef/services_content.xml
+++ b/applications/content/servicedef/services_content.xml
@@ -487,8 +487,8 @@
</type-validate>
</attribute>
</service>
- <service name="indexContentKeywords" engine="simple"
-
location="component://content/minilang/content/ContentServices.xml"
invoke="indexContentKeywords" auth="false">
+ <service name="indexContentKeywords" engine="groovy"
+
location="component://content/groovyScripts/content/ContentServices.groovy"
invoke="indexContentKeywords" auth="false">
<description>Index the Keywords for a Content</description>
<attribute name="contentId" type="String" mode="IN" optional="false">
<type-validate>
@@ -497,8 +497,8 @@
</attribute>
<attribute name="contentInstance"
type="org.apache.ofbiz.entity.GenericValue" mode="IN" optional="true"/>
</service>
- <service name="forceIndexContentKeywords" engine="simple"
-
location="component://content/minilang/content/ContentServices.xml"
invoke="forceIndexContentKeywords" auth="true">
+ <service name="forceIndexContentKeywords" engine="groovy"
+
location="component://content/groovyScripts/content/ContentServices.groovy"
invoke="forceIndexContentKeywords" auth="true">
<description>Induce all the keywords of a content, ignoring the flag
in the Content.</description>
<permission-service service-name="genericContentPermission"
main-action="CREATE"/>
<attribute name="contentId" type="String" mode="IN" optional="false">