Author: hansbak
Date: Thu Jul 7 03:59:31 2011 New Revision: 1143647 URL: http://svn.apache.org/viewvc?rev=1143647&view=rev Log: add services to create the alternative seo friendly url's for contant from the contentname, only when they are missing in the current locale. Also updated the related demo data Modified: ofbiz/trunk/applications/content/script/org/ofbiz/content/content/ContentServices.xml ofbiz/trunk/applications/content/servicedef/secas.xml ofbiz/trunk/applications/content/servicedef/services.xml ofbiz/trunk/specialpurpose/ecommerce/data/DemoContentAltUrl.xml ofbiz/trunk/specialpurpose/ecommerce/widget/blog/BlogScreens.xml Modified: ofbiz/trunk/applications/content/script/org/ofbiz/content/content/ContentServices.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/script/org/ofbiz/content/content/ContentServices.xml?rev=1143647&r1=1143646&r2=1143647&view=diff ============================================================================== --- ofbiz/trunk/applications/content/script/org/ofbiz/content/content/ContentServices.xml (original) +++ ofbiz/trunk/applications/content/script/org/ofbiz/content/content/ContentServices.xml Thu Jul 7 03:59:31 2011 @@ -1278,39 +1278,62 @@ </simple-method> <simple-method method-name="createContentAlternativeUrl" short-description="Create Content Alternative URLs."> - <set field="contentId" from-field="parameters.contentId"/> - <entity-one value-field="content" entity-name="Content"> - <field-map field-name="contentId" from-field="contentId"/> - </entity-one> - <if-not-empty field="content.contentName"> - <call-class-method method-name="invalidCharacter" class-name="org.ofbiz.common.UrlServletHelper" ret-field="altUrl"> - <field field="content.contentName"/> - </call-class-method> - <set field="altUrl" value="/${altUrl}-${content.contentId}-content"/> - <sequenced-id sequence-name="DataResource" field="createDataResourceCtx.dataResourceId"/> - <set field="createDataResourceCtx.dataResourceTypeId" value="ELECTRONIC_TEXT"/> - <set field="createDataResourceCtx.dataTemplateTypeId" value="FTL"/> - <set field="createDataResourceCtx.objectInfo" from-field="altUrl"/> - <set field="createDataResourceCtx.statusId" value="CTNT_IN_PROGRESS"/> - <call-service service-name="createDataResource" in-map-name="createDataResourceCtx" include-user-login="true"> - <result-to-field result-name="dataResourceId" field="dataResourceId"/> - </call-service> - <set field="electronicTextCtx.dataResourceId" from-field="dataResourceId"/> - <set field="electronicTextCtx.textData" from-field="content.contentName"/> - <call-service service-name="createElectronicText" in-map-name="electronicTextCtx"></call-service> - - <sequenced-id sequence-name="Content" field="contentCtx.contentId"/> - <set field="contentCtx.contentTypeId" value="DOCUMENT"/> - <set field="contentCtx.dataResourceId" from-field="dataResourceId"/> - <call-service service-name="createContent" in-map-name="contentCtx" include-user-login="true"> - <result-to-field result-name="contentId" field="contentIdTo"/> - </call-service> - - <set field="createContentAssocCtx.contentId" from-field="content.contentId"/> - <set field="createContentAssocCtx.contentIdTo" from-field="contentIdTo"/> - <set field="createContentAssocCtx.contentAssocTypeId" value="ALTERNATIVE_URL"/> - <call-service service-name="createContentAssoc" in-map-name="createContentAssocCtx"/> - </if-not-empty> + <set field="defaultLocaleString" from-field="parameters.locale"/> + <entity-condition list="contents" entity-name="Content"> + <condition-list combine="and"> + <condition-expr field-name="contentName" operator="not-equals" from-field="nullField"/> + <condition-expr field-name="contentId" operator="equals" from-field="parameters.contentId" ignore-if-empty="true" ignore-if-null="true"/> + </condition-list> + <select-field field-name="contentId"/> + <select-field field-name="contentName"/> + <select-field field-name="localeString"/> + </entity-condition> + <iterate entry="content" list="contents"> + <set field="localeString" from-field="content.localeString" default-value="${defaultLocaleString}"/> + <entity-condition list="contentAssocDataResources" entity-name="ContentAssocDataResourceViewTo"> + <condition-list combine="and"> + <condition-expr field-name="caContentAssocTypeId" operator="equals" value="ALTERNATIVE_URL"/> + <condition-expr field-name="contentIdStart" operator="equals" from-field="content.contentId"/> + <condition-expr field-name="localeString" operator="equals" from-field="localeString"/> + </condition-list> + <select-field field-name="contentIdStart"/> + <select-field field-name="dataResourceId"/> + <select-field field-name="localeString"/> + <select-field field-name="caFromDate"/> + <select-field field-name="caThruDate"/> + </entity-condition> + <filter-list-by-date list="contentAssocDataResources" from-field-name="caFromDate" thru-field-name="caThruDate"/> + <if-empty field="contentAssocDataResources"> + <call-class-method method-name="invalidCharacter" class-name="org.ofbiz.common.UrlServletHelper" ret-field="altUrl"> + <field field="content.contentName"/> + </call-class-method> + <set field="altUrl" value="/${altUrl}-${content.contentId}-content"/> + <sequenced-id sequence-name="DataResource" field="createDataResourceCtx.dataResourceId"/> + <set field="createDataResourceCtx.dataResourceTypeId" value="ELECTRONIC_TEXT"/> + <set field="createDataResourceCtx.dataTemplateTypeId" value="FTL"/> + <set field="createDataResourceCtx.localeString" from-field="localeString"/> + <set field="createDataResourceCtx.objectInfo" from-field="altUrl"/> + <set field="createDataResourceCtx.statusId" value="CTNT_IN_PROGRESS"/> + <call-service service-name="createDataResource" in-map-name="createDataResourceCtx" include-user-login="true"> + <result-to-field result-name="dataResourceId" field="dataResourceId"/> + </call-service> + <set field="electronicTextCtx.dataResourceId" from-field="dataResourceId"/> + <set field="electronicTextCtx.textData" from-field="content.contentName"/> + <call-service service-name="createElectronicText" in-map-name="electronicTextCtx"></call-service> + + <sequenced-id sequence-name="Content" field="contentCtx.contentId"/> + <set field="contentCtx.contentTypeId" value="DOCUMENT"/> + <set field="contentCtx.dataResourceId" from-field="dataResourceId"/> + <set field="contentCtx.localeString" from-field="localeString"/> + <call-service service-name="createContent" in-map-name="contentCtx" include-user-login="true"> + <result-to-field result-name="contentId" field="contentIdTo"/> + </call-service> + + <set field="createContentAssocCtx.contentId" from-field="content.contentId"/> + <set field="createContentAssocCtx.contentIdTo" from-field="contentIdTo"/> + <set field="createContentAssocCtx.contentAssocTypeId" value="ALTERNATIVE_URL"/> + <call-service service-name="createContentAssoc" in-map-name="createContentAssocCtx"/> + </if-empty> + </iterate> </simple-method> - </simple-methods> Modified: ofbiz/trunk/applications/content/servicedef/secas.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/servicedef/secas.xml?rev=1143647&r1=1143646&r2=1143647&view=diff ============================================================================== --- ofbiz/trunk/applications/content/servicedef/secas.xml (original) +++ ofbiz/trunk/applications/content/servicedef/secas.xml Thu Jul 7 03:59:31 2011 @@ -180,7 +180,7 @@ under the License. </eca> <eca service="createContent" event="return"> + <condition field-name="contentId" operator="is-not-empty"/> <action service="createContentAlternativeUrl" mode="sync" run-as-user="system"/> </eca> - </service-eca> Modified: ofbiz/trunk/applications/content/servicedef/services.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/servicedef/services.xml?rev=1143647&r1=1143646&r2=1143647&view=diff ============================================================================== --- ofbiz/trunk/applications/content/servicedef/services.xml (original) +++ ofbiz/trunk/applications/content/servicedef/services.xml Thu Jul 7 03:59:31 2011 @@ -1201,6 +1201,6 @@ <service name="createContentAlternativeUrl" engine="simple" location="component://content/script/org/ofbiz/content/content/ContentServices.xml" invoke="createContentAlternativeUrl" auth="true"> <description>Create Content Alternative URL</description> - <attribute name="contentId" mode="IN" type="String" optional="false"></attribute> + <attribute name="contentId" mode="IN" type="String" optional="true"></attribute> </service> </services> Modified: ofbiz/trunk/specialpurpose/ecommerce/data/DemoContentAltUrl.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/data/DemoContentAltUrl.xml?rev=1143647&r1=1143646&r2=1143647&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/data/DemoContentAltUrl.xml (original) +++ ofbiz/trunk/specialpurpose/ecommerce/data/DemoContentAltUrl.xml Thu Jul 7 03:59:31 2011 @@ -21,19 +21,19 @@ under the License. <!-- Demo Content Alternative Url --> <!-- The content alternative url come from the contentName in the Content entity.--> - <DataResource dataResourceId="DRS_CNT_URL005" dataResourceTypeId="ELECTRONIC_TEXT" statusId="CTNT_IN_PROGRESS" objectInfo="/Cute-Kid-BLG10000-content"/> + <DataResource dataResourceId="DRS_CNT_URL005" dataResourceTypeId="ELECTRONIC_TEXT" statusId="CTNT_IN_PROGRESS" objectInfo="/Cute-Kid-BLG10000-content" localeString="en_US"/> <ElectronicText dataResourceId="DRS_CNT_URL005" textData="Cute Kid"/> - <Content contentId="CNT_ALTURL_005" contentTypeId="DOCUMENT" dataResourceId="DRS_CNT_URL005" statusId="CTNT_IN_PROGRESS"/> + <Content contentId="CNT_ALTURL_005" contentTypeId="DOCUMENT" dataResourceId="DRS_CNT_URL005" statusId="CTNT_IN_PROGRESS" localeString="en_US"/> <ContentAssoc contentId="BLG10000" contentIdTo="CNT_ALTURL_005" contentAssocTypeId="ALTERNATIVE_URL" fromDate="2011-06-23 01:01:01"></ContentAssoc> - <DataResource dataResourceId="DRS_CNT_URL006" dataResourceTypeId="ELECTRONIC_TEXT" statusId="CTNT_IN_PROGRESS" objectInfo="/Next-Linus-BLG10010-content"/> + <DataResource dataResourceId="DRS_CNT_URL006" dataResourceTypeId="ELECTRONIC_TEXT" statusId="CTNT_IN_PROGRESS" objectInfo="/Next-Linus-BLG10010-content" localeString="en_US"/> <ElectronicText dataResourceId="DRS_CNT_URL006" textData="Next Linus"/> - <Content contentId="CNT_ALTURL_006" contentTypeId="DOCUMENT" dataResourceId="DRS_CNT_URL006" statusId="CTNT_IN_PROGRESS"/> + <Content contentId="CNT_ALTURL_006" contentTypeId="DOCUMENT" dataResourceId="DRS_CNT_URL006" statusId="CTNT_IN_PROGRESS" localeString="en_US"/> <ContentAssoc contentId="BLG10010" contentIdTo="CNT_ALTURL_006" contentAssocTypeId="ALTERNATIVE_URL" fromDate="2011-06-23 01:01:01"></ContentAssoc> - <DataResource dataResourceId="DRS_CNT_URL007" dataResourceTypeId="ELECTRONIC_TEXT" statusId="CTNT_IN_PROGRESS" objectInfo="/2008-Elections-BLG10007-content"/> + <DataResource dataResourceId="DRS_CNT_URL007" dataResourceTypeId="ELECTRONIC_TEXT" statusId="CTNT_IN_PROGRESS" objectInfo="/2008-Elections-BLG10007-content" localeString="en_US"/> <ElectronicText dataResourceId="DRS_CNT_URL007" textData="2008 Elections"/> - <Content contentId="CNT_ALTURL_007" contentTypeId="DOCUMENT" dataResourceId="DRS_CNT_URL007" statusId="CTNT_IN_PROGRESS"/> + <Content contentId="CNT_ALTURL_007" contentTypeId="DOCUMENT" dataResourceId="DRS_CNT_URL007" statusId="CTNT_IN_PROGRESS" localeString="en_US"/> <ContentAssoc contentId="BLG10007" contentIdTo="CNT_ALTURL_007" contentAssocTypeId="ALTERNATIVE_URL" fromDate="2011-06-23 01:01:01"></ContentAssoc> </entity-engine-xml> Modified: ofbiz/trunk/specialpurpose/ecommerce/widget/blog/BlogScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/specialpurpose/ecommerce/widget/blog/BlogScreens.xml?rev=1143647&r1=1143646&r2=1143647&view=diff ============================================================================== --- ofbiz/trunk/specialpurpose/ecommerce/widget/blog/BlogScreens.xml (original) +++ ofbiz/trunk/specialpurpose/ecommerce/widget/blog/BlogScreens.xml Thu Jul 7 03:59:31 2011 @@ -676,6 +676,7 @@ <entity-condition entity-name="ContentAssocViewTo" list="blogs" use-cache="true"> <condition-list combine="and"> <condition-expr field-name="contentIdStart" operator="equals" value="BLOGROOT"/> + <condition-expr field-name="caContentAssocTypeId" operator="equals" value="SUB_CONTENT"/> <condition-list combine="or"> <condition-expr field-name="caFromDate" operator="equals" from-field="null"/> <condition-expr field-name="caFromDate" operator="less-equals" from-field="nowTimestamp"/> |
Free forum by Nabble | Edit this page |