Skip to content
This repository has been archived by the owner on May 9, 2020. It is now read-only.

Commit

Permalink
A slightly modified patch from Nicolas Malin "change serviceName by c…
Browse files Browse the repository at this point in the history
…ustomMethod on Content " https://issues.apache.org/jira/browse/OFBIZ-5020

When you used a content as template, the content.serviceName value used to call the context populate service before rendering.
I propose to replace serviceName field by customMethodId and use customMethod pattern for more flexibility.
serviceName field is kept for backward compatibility

Thanks to Scott and Adrian for support


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1379937 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
JacquesLeRoux committed Sep 2, 2012
1 parent b4fb220 commit b86cc8b
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 6 deletions.
4 changes: 4 additions & 0 deletions applications/accounting/data/AccountingTypeData.xml
Expand Up @@ -728,11 +728,13 @@ under the License.
<CustomMethodType customMethodTypeId="FIN_CAPTURE" parentTypeId="" hasTable="N" description="FIN account capture methods"/>
<CustomMethodType customMethodTypeId="FIN_REFUND" parentTypeId="" hasTable="N" description="FIN account refund methods"/>
<CustomMethodType customMethodTypeId="FIN_RELEASE" parentTypeId="" hasTable="N" description="FIN account release methods"/>
<CustomMethodType customMethodTypeId="FIN_PURCHASE" parentTypeId="" hasTable="N" description="FIN account purchase methods"/>

<CustomMethodType customMethodTypeId="GIFT_AUTH" parentTypeId="" hasTable="N" description="GIFT card authorize methods"/>
<CustomMethodType customMethodTypeId="GIFT_CAPTURE" parentTypeId="" hasTable="N" description="GIFT card capture methods"/>
<CustomMethodType customMethodTypeId="GIFT_REFUND" parentTypeId="" hasTable="N" description="GIFT card refund methods"/>
<CustomMethodType customMethodTypeId="GIFT_RELEASE" parentTypeId="" hasTable="N" description="GIFT card release methods"/>
<CustomMethodType customMethodTypeId="GIFT_PURCHASE" parentTypeId="" hasTable="N" description="GIFT card purchase methods"/>

<CustomMethodType customMethodTypeId="PAYPAL_AUTH" parentTypeId="" hasTable="N" description="PayPal authorize methods"/>
<CustomMethodType customMethodTypeId="PAYPAL_CAPTURE" parentTypeId="" hasTable="N" description="PayPal capture methods"/>
Expand Down Expand Up @@ -809,6 +811,7 @@ under the License.
<CustomMethod customMethodId="FIN_CAPTURE_OFBIZ" customMethodTypeId="FIN_CAPTURE" customMethodName="ofbFaCapture" description="FIN account capture"/>
<CustomMethod customMethodId="FIN_REFUND_OFBIZ" customMethodTypeId="FIN_REFUND" customMethodName="ofbFaRefund" description="FIN account refund"/>
<CustomMethod customMethodId="FIN_RELEASE_OFBIZ" customMethodTypeId="FIN_RELEASE" customMethodName="ofbFaRelease" description="FIN account release"/>
<CustomMethod customMethodId="FIN_PURCH_OFBIZ" customMethodTypeId="FIN_PURCHASE" customMethodName="createPartyFinAccountFromPurchase" description="FIN account purchase"/>

<CustomMethod customMethodId="GIFT_AUTH_OFBIZ" customMethodTypeId="GIFT_AUTH" customMethodName="ofbGcAuthorize" description="GIFT card authorize"/>
<CustomMethod customMethodId="GIFT_AUTH_ALWAYSAPPR" customMethodTypeId="GIFT_AUTH" customMethodName="alwaysApproveGCProcessor" description="GIFT card always authorize"/>
Expand All @@ -820,6 +823,7 @@ under the License.
<CustomMethod customMethodId="GIFT_RELEASE_OFBIZ" customMethodTypeId="GIFT_RELEASE" customMethodName="ofbGcRelease" description="GIFT card release"/>
<CustomMethod customMethodId="GIFT_RELEASE_TEST" customMethodTypeId="GIFT_RELEASE" customMethodName="testGCRelease" description="GIFT card test release"/>
<CustomMethod customMethodId="GIFT_RELEASE_VALUEL" customMethodTypeId="GIFT_RELEASE" customMethodName="valueLinkRelease" description="GIFT card ValueLink release"/>
<CustomMethod customMethodId="GIFT_PURCH_OFBIZ" customMethodTypeId="GIFT_PURCHASE" customMethodName="ofbGcPurchase" description="GIFT card Purchase Fulfillment Service"/>

<CustomMethod customMethodId="PAYPAL_AUTH_PFP" customMethodTypeId="PAYPAL_AUTH" customMethodName="payflowPayPalProcessor" description="Payflow PayPal payment authorize"/>
<CustomMethod customMethodId="PAYPAL_AUTH" customMethodTypeId="PAYPAL_AUTH" customMethodName="payPalProcessor" description="PayPal payment authorize"/>
Expand Down
8 changes: 7 additions & 1 deletion applications/content/entitydef/entitymodel.xml
Expand Up @@ -159,7 +159,10 @@ under the License.
<field name="dataSourceId" type="id"></field>
<field name="statusId" type="id"></field>
<field name="privilegeEnumId" type="id"></field>
<field name="serviceName" type="long-varchar"></field>
<field name="serviceName" type="long-varchar">
<description>Deprecated : use customMethod pattern instead of. Kept for backward compatibility</description>
</field>
<field name="customMethodId" type="id"></field>
<field name="contentName" type="name"></field>
<field name="description" type="description"></field>
<field name="localeString" type="very-short"></field>
Expand Down Expand Up @@ -187,6 +190,9 @@ under the License.
<relation type="one" fk-name="CONTENT_PRIVENM" title="Privilege" rel-entity-name="Enumeration">
<key-map field-name="privilegeEnumId" rel-field-name="enumId"/>
</relation>
<relation type="one" fk-name="CONTENT_CUSTMET" rel-entity-name="CustomMethod">
<key-map field-name="customMethodId"/>
</relation>
<!-- the relationship to MimeType is one-nofk so that you can still do a lookup on MimeType but a new
and unexpected mime type would not cause a foreign key constraint violation, so MimeType can store the
most common mime types instead of an exhaustive list of all possible mime types -->
Expand Down
Expand Up @@ -27,6 +27,7 @@ under the License.
<process field="dataResourceId"><copy to-field="dataResourceId" replace="true" set-if-null="false"/></process>
<process field="dataSourceId"><copy to-field="dataSourceId" replace="true" set-if-null="false"/></process>
<process field="statusId"><copy to-field="statusId" replace="true" set-if-null="false"/></process>
<process field="customMethodId"><copy to-field="customMethodId" replace="true" set-if-null="false"/></process>
<process field="serviceName"><copy to-field="serviceName" replace="true" set-if-null="false"/></process>
<process field="contentName"><copy to-field="contentName" replace="true" set-if-null="false"/></process>
<process field="description"><copy to-field="description" replace="true" set-if-null="false"/></process>
Expand Down Expand Up @@ -112,6 +113,7 @@ under the License.
<process field="dataResourceId"><copy to-field="dataResourceId" replace="true" set-if-null="false"/></process>
<process field="dataSourceId"><copy to-field="dataSourceId" replace="true" set-if-null="false"/></process>
<process field="statusId"><copy to-field="statusId" replace="true" set-if-null="false"/></process>
<process field="customMethodId"><copy to-field="customMethodId" replace="true" set-if-null="false"/></process>
<process field="serviceName"><copy to-field="serviceName" replace="true" set-if-null="false"/></process>
<process field="contentName"><copy to-field="contentName" replace="true" set-if-null="false"/></process>
<process field="description"><copy to-field="description" replace="true" set-if-null="false"/></process>
Expand Down
Expand Up @@ -177,7 +177,12 @@ public static void renderContentAsText(LocalDispatcher dispatcher, Delegator del
Map<String,Object>templateContext, Locale locale, String mimeTypeId, boolean cache, List<GenericValue> webAnalytics) throws GeneralException, IOException {
// if the content has a service attached run the service

String serviceName = content.getString("serviceName");
String serviceName = content.getString("serviceName"); //Kept for backward compatibility
GenericValue custMethod = null;
if (UtilValidate.isNotEmpty(content.getString("customMethodId"))) {
custMethod = delegator.findOne("CustomMethod", UtilMisc.toMap("customMethodId", content.get("customMethodId")), true);
}
if (custMethod != null) serviceName = custMethod.getString("customMethodName");
if (dispatcher != null && UtilValidate.isNotEmpty(serviceName)) {
DispatchContext dctx = dispatcher.getDispatchContext();
ModelService service = dctx.getModelService(serviceName);
Expand Down
14 changes: 12 additions & 2 deletions applications/order/src/org/ofbiz/order/order/OrderServices.java
Expand Up @@ -3337,8 +3337,18 @@ public static Map<String, Object> fulfillDigitalItems(DispatchContext ctx, Map<S

String fulfillmentType = productContentItem.getString("productContentTypeId");
if ("FULFILLMENT_EXTASYNC".equals(fulfillmentType) || "FULFILLMENT_EXTSYNC".equals(fulfillmentType)) {
// enternal service fulfillment
String fulfillmentService = (String) content.get("serviceName");
// external service fulfillment
String fulfillmentService = (String) content.get("serviceName"); // Kept for backward compatibility
GenericValue custMethod = null;
if (UtilValidate.isNotEmpty(content.getString("customMethodId"))) {
try {
custMethod = delegator.findOne("CustomMethod", UtilMisc.toMap("customMethodId", content.get("customMethodId")), true);
} catch (GenericEntityException e) {
Debug.logError(e,"ERROR: Cannot get CustomMethod associate to Content entity: " + e.getMessage(),module);
continue;
}
}
if (custMethod != null) fulfillmentService = custMethod.getString("customMethodName");
if (fulfillmentService == null) {
Debug.logError("ProductContent of type FULFILLMENT_EXTERNAL had Content with empty serviceName, can not run fulfillment", module);
}
Expand Down
2 changes: 1 addition & 1 deletion specialpurpose/ecommerce/data/DemoFinAccount.xml
Expand Up @@ -83,7 +83,7 @@
<ProductStoreSurveyAppl productStoreSurveyId="1100" productStoreId="9000" surveyApplTypeId="CART_ADD" surveyId="1100" productId="FA-001" fromDate="2003-11-24 16:00:02.467" surveyTemplate="/applications/content/template/survey/genericsurvey.ftl" lastUpdatedStamp="2003-12-04 21:40:23.27" lastUpdatedTxStamp="2003-12-04 21:40:20.607"/>

<!-- fulfillment service -->
<Content contentId="FA_ACTIVATION" serviceName="createPartyFinAccountFromPurchase"/>
<Content contentId="FA_ACTIVATION" customMethodId="FIN_PURCH_OFBIZ"/>

<!-- associate the fulfillment service with the products -->
<ProductContent productId="FA-001" contentId="FA_ACTIVATION" productContentTypeId="FULFILLMENT_EXTASYNC" fromDate="2000-01-01 00:00:00"/>
Expand Down
Expand Up @@ -25,7 +25,7 @@ under the License.
purchaseSurveyId="1000" purchSurveySendTo="recipientEmail" purchSurveyCopyMe="copyMe" accountCodeLength="12" pinCodeLength="4" accountValidDays="365" authValidDays="30"/>

<!-- service for purchasing gift certificate configured as a Content and to be associated with products -->
<Content contentId="GC_PURCHASE" serviceName="ofbGcPurchase"/>
<Content contentId="GC_PURCHASE" customMethodId="GIFT_PURCH_OFBIZ"/>

<!-- associate gift certificate purchase fulfillment services with products. virtual products ok. MUST be async fulfillment -
synchronous fulfillment can cause database lock problems -->
Expand Down

0 comments on commit b86cc8b

Please sign in to comment.