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 2015/08/10 18:15:38 UTC

svn commit: r1695126 [2/22] - in /ofbiz/trunk: applications/accounting/src/org/ofbiz/accounting/thirdparty/authorizedotnet/ applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/ applications/content/src/org/ofbiz/content/webapp/ftl/ ap...

Modified: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java?rev=1695126&r1=1695125&r2=1695126&view=diff
==============================================================================
--- ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java (original)
+++ ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java Mon Aug 10 16:15:37 2015
@@ -1,259 +1,259 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *******************************************************************************/
-
-package org.ofbiz.accounting.thirdparty.securepay;
-
-import java.math.BigDecimal;
-import java.util.List;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.ofbiz.base.util.Debug;
-import org.ofbiz.base.util.UtilMisc;
-import org.ofbiz.base.util.UtilValidate;
-import org.ofbiz.entity.GenericValue;
-import org.ofbiz.service.GenericServiceException;
-import org.ofbiz.service.ModelService;
-import org.ofbiz.service.testtools.OFBizTestCase;
-
-public class SecurePayServiceTest extends OFBizTestCase{
-
-    public SecurePayServiceTest(String name) {
-        super(name);
-    }
-    
-    public static final String module = SecurePayServiceTest.class.getName();
-
-    // test data
-    protected GenericValue emailAddr = null;
-    protected String orderId = null;
-    protected GenericValue creditCard = null;
-    protected GenericValue billingAddress = null;
-    protected GenericValue shippingAddress = null;
-    protected BigDecimal creditAmount = null;
-    protected String configFile = null;
-    protected GenericValue orderPaymentPreference = null;
-    protected List<Object> orderItems = null;
-    protected Map<String, Object> orderItemMap = null;
-    protected GenericValue billToParty = null;
-    protected String paymentGatewayConfigId = null;
-    protected BigDecimal refundAmount = null;
-    protected GenericValue paymentGatewayResponse = null;
-    protected String releaseRefNum = null;
-
-    @Override
-    protected void setUp() throws Exception {
-        // populate test data
-        configFile = "paymentTest.properties";
-        creditAmount = new BigDecimal("234.51");
-        emailAddr = delegator.makeValue("ContactMech", UtilMisc.toMap(
-                "infoString","test@hansbakker.com"));
-        orderId = "Demo1002";
-        creditCard = delegator.makeValue("CreditCard", UtilMisc.toMap(
-                "cardType","CCT_VISA",
-                "expireDate","10/2011",  // mm/yyyy, gets converted to mm/yy
-                "cardNumber","4444333322221111"));
-        billingAddress = delegator.makeValue("PostalAddress", UtilMisc.toMap(
-                "toName","The customer Name",
-                "address1","The customer billingAddress1",
-                "address2","The customer billingAddress2",
-                "city","The customer city",
-                "stateProvinceGeoId", "NLD"));
-        shippingAddress = delegator.makeValue("PostalAddress", UtilMisc.toMap(
-                "toName","The customer Name",
-                "address1","The customer shippingStreet1",
-                "address2","The customer shippingStreet2",
-                "city","The customer city",
-                "stateProvinceGeoId", "NLD",
-                "postalCode","12345"));
-        orderItemMap = UtilMisc.<String, Object>toMap(
-                "orderId", "Demo1002", 
-                "orderItemSeqId", "00001", 
-                "orderItemTypeId", "PRODUCT_ORDER_ITEM", 
-                "productId", "GZ-1000",
-                "prodCatalogId", "DemoCatalog", 
-                "quantity" , new BigDecimal("2.000000"), 
-                "unitPrice", new BigDecimal("59.00"),
-                "statusId" ,"ITEM_COMPLETED"
-                );
-        orderItems = UtilMisc.<Object>toList(orderItemMap);
-        billToParty = delegator.makeValue("Party" , UtilMisc.toMap("partyId", "DemoCustomer"));
-        paymentGatewayConfigId = "SECUREPAY_CONFIG";
-        refundAmount = new BigDecimal("100.08");
-        orderPaymentPreference = delegator.makeValue("OrderPaymentPreference", UtilMisc.toMap(
-            "orderPaymentPreferenceId", "testOrder1000_01", 
-            "orderId", "Demo1002", 
-            "paymentMethodTypeId", "CREDIT_CARD", 
-            "maxAmount", new BigDecimal("200.00"), 
-            "statusId", "PAYMENT_AUTHORIZED"));
-        
-        GenericValue checkOrderPaymentPreference = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderPaymentPreferenceId", "testOrder1000_01").queryOne();
-        if (UtilValidate.isEmpty(checkOrderPaymentPreference)) {
-            orderPaymentPreference.create();
-        }
-    }
-
-    public void testAuth() throws Exception{
-        Debug.logInfo("=====[testAuth] starting....", module);
-        try {
-            Map<String, Object> serviceInput = UtilMisc.<String, Object>toMap(
-                    "paymentConfig", configFile,
-                    "billToParty", billToParty,
-                    "billToEmail", emailAddr,
-                    "orderPaymentPreference", orderPaymentPreference,
-                    "orderItems", orderItems,
-                    "creditCard", creditCard,
-                    "billingAddress", billingAddress,
-                    "shippingAddress", shippingAddress,
-                    "orderId", orderId,
-                    "currency", "AUD"
-           );
-            serviceInput.put("processAmount", new BigDecimal("100.08"));
-
-            // run the service
-            Map<String, Object> result = dispatcher.runSync("ofbScAuthorize",serviceInput);
-
-            // verify the results
-            String responseMessage = (String) result.get(ModelService.RESPONSE_MESSAGE);
-            Debug.logInfo("[testCCAuth] responseMessage: " + responseMessage, module);
-            TestCase.assertEquals("Service result is success", ModelService.RESPOND_SUCCESS, responseMessage);
-
-            if (((Boolean) result.get("authResult")).equals(new Boolean(false))) {          // returnCode ok?
-                Debug.logInfo("[testAuth] Error Messages from SecurePay: " + result.get("internalRespMsgs"), module);
-                TestCase.fail("Returned messages:" + result.get("internalRespMsgs"));
-            } else {
-                Debug.logInfo("[testAuth] Result from SecurePay: " + result, module);
-                String authRefNum = (String) result.get("authRefNum");
-                BigDecimal processAmount =  (BigDecimal) result.get("processAmount");
-                paymentGatewayResponse = delegator.makeValue("PaymentGatewayResponse" , UtilMisc.toMap(
-                        "paymentGatewayResponseId", "testOrder1000_01",
-                        "orderPaymentPreferenceId", "testOrder1000_01",
-                        "amount" , processAmount,
-                        "referenceNum", authRefNum,
-                        "paymentMethodTypeId", "CREDIT_CARD",
-                        "paymentServiceTypeEnumId", "PRDS_PAY_AUTH",
-                        "currencyUomId", "AUD"
-                        ));
-                GenericValue checkPaymentGatewayResponse = EntityQuery.use(delegator).from("PaymentGatewayResponse").where("paymentGatewayResponseId", "testOrder1000_01").queryOne();
-                if (UtilValidate.isEmpty(checkPaymentGatewayResponse)) {
-                    paymentGatewayResponse.create();
-                }
-            }
-        } catch (GenericServiceException ex) {
-            TestCase.fail(ex.getMessage());
-        }
-    }
-
-    public void testdoCapture() throws Exception {
-        Debug.logInfo("=====[testdoCapture] starting....", module);
-        GenericValue paymentGatewayResponse = EntityQuery.use(delegator).from("PaymentGatewayResponse").where("paymentGatewayResponseId", "testOrder1000_01").queryOne();
-        try {
-            Map<String, Object> serviceInput = UtilMisc.<String, Object>toMap(
-                    "paymentConfig", configFile,
-                    "orderPaymentPreference", orderPaymentPreference,
-                    "authTrans", paymentGatewayResponse
-           );
-            serviceInput.put("captureAmount", refundAmount);
-
-            // run the service
-            Map<String, Object> result = dispatcher.runSync("ofbScCapture",serviceInput);
-
-            // verify the results
-            String responseMessage = (String) result.get(ModelService.RESPONSE_MESSAGE);
-            Debug.logInfo("[testdoCapture] responseMessage: " + responseMessage, module);
-            TestCase.assertEquals("Service result is success", ModelService.RESPOND_SUCCESS, responseMessage);
-
-            if (((Boolean) result.get("captureResult")).equals(new Boolean(false))) {          // returnCode ok?
-                Debug.logInfo("[testdoCapture] Error Messages from SecurePay: " + result.get("internalRespMsgs"), module);
-                TestCase.fail("Returned messages:" + result.get("internalRespMsgs"));
-            } else {
-                String captureRefNum = (String) result.get("captureRefNum");
-                GenericValue checkPaymentGatewayResponse = EntityQuery.use(delegator).from("PaymentGatewayResponse").where("paymentGatewayResponseId", "testOrder1000_01").queryOne();
-                checkPaymentGatewayResponse.set("referenceNum", captureRefNum);
-                checkPaymentGatewayResponse.store();
-                Debug.logInfo("[testdoCapture] Result from SecurePay: " + result, module);
-            }
-            
-        } catch (GenericServiceException ex) {
-            TestCase.fail(ex.getMessage());
-        }
-    }
-
-    public void testdoRefund() throws Exception {
-        Debug.logInfo("=====[testdoRefund] starting....", module);
-        try {
-            Map<String, Object> serviceInput = UtilMisc.toMap(
-                    "paymentConfig", configFile,
-                    "orderPaymentPreference", orderPaymentPreference
-           );
-            serviceInput.put("refundAmount", refundAmount);
-            // run the service
-            Map<String, Object> result = dispatcher.runSync("ofbScRefund", serviceInput);
-
-            // verify the results
-            String responseMessage = (String) result.get(ModelService.RESPONSE_MESSAGE);
-            Debug.logInfo("[testdoRefund] responseMessage: " + responseMessage, module);
-            TestCase.assertEquals("Service result is success", ModelService.RESPOND_SUCCESS, responseMessage);
-
-            if (((Boolean) result.get("refundResult")).equals(new Boolean(false))) {          // returnCode ok?
-                Debug.logInfo("[testdoRefund] Error Messages from SecurePay: " + result.get("internalRespMsgs"), module);
-                TestCase.fail("Returned messages:" + result.get("internalRespMsgs"));
-            } else {
-                Debug.logInfo("[testdoRefund] Result from SecurePay: " + result, module);
-            }
-
-        } catch (GenericServiceException ex) {
-            TestCase.fail(ex.getMessage());
-        }
-    }
-
-    public void testdoCredit() throws Exception{
-        Debug.logInfo("=====[testdoCredit] starting....", module);
-        try {
-            Map<String, Object> serviceInput = UtilMisc.toMap(
-                    "paymentConfig", configFile,
-                    "billToParty", billToParty,
-                    "billToEmail", emailAddr,
-                    "orderItems", orderItems,
-                    "creditCard", creditCard,
-                    "billingAddress", billingAddress,
-                    "referenceCode", orderId,
-                    "currency", "AUD"
-           );
-            serviceInput.put("creditAmount", creditAmount);
-            // run the service
-            Map<String, Object> result = dispatcher.runSync("ofbScCCCredit",serviceInput);
-            // verify the results
-            String responseMessage = (String) result.get(ModelService.RESPONSE_MESSAGE);
-            Debug.logInfo("[testdoCredit] responseMessage: " + responseMessage, module);
-            TestCase.assertEquals("Service result is success", ModelService.RESPOND_SUCCESS, responseMessage);
-
-            if (((Boolean) result.get("creditResult")).equals(new Boolean(false))) {          // returnCode ok?
-                Debug.logInfo("[testdoCredit] Error Messages from SecurePay: " + result.get("internalRespMsgs"), module);
-                TestCase.fail("Returned messages:" + result.get("internalRespMsgs"));
-            } else {
-                Debug.logInfo("[testdoCredit] Result from SecurePay: " + result, module);
-            }
-
-        } catch (GenericServiceException ex) {
-            TestCase.fail(ex.getMessage());
-        }
-    }
-}
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+
+package org.ofbiz.accounting.thirdparty.securepay;
+
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.service.GenericServiceException;
+import org.ofbiz.service.ModelService;
+import org.ofbiz.service.testtools.OFBizTestCase;
+
+public class SecurePayServiceTest extends OFBizTestCase{
+
+    public SecurePayServiceTest(String name) {
+        super(name);
+    }
+    
+    public static final String module = SecurePayServiceTest.class.getName();
+
+    // test data
+    protected GenericValue emailAddr = null;
+    protected String orderId = null;
+    protected GenericValue creditCard = null;
+    protected GenericValue billingAddress = null;
+    protected GenericValue shippingAddress = null;
+    protected BigDecimal creditAmount = null;
+    protected String configFile = null;
+    protected GenericValue orderPaymentPreference = null;
+    protected List<Object> orderItems = null;
+    protected Map<String, Object> orderItemMap = null;
+    protected GenericValue billToParty = null;
+    protected String paymentGatewayConfigId = null;
+    protected BigDecimal refundAmount = null;
+    protected GenericValue paymentGatewayResponse = null;
+    protected String releaseRefNum = null;
+
+    @Override
+    protected void setUp() throws Exception {
+        // populate test data
+        configFile = "paymentTest.properties";
+        creditAmount = new BigDecimal("234.51");
+        emailAddr = delegator.makeValue("ContactMech", UtilMisc.toMap(
+                "infoString","test@hansbakker.com"));
+        orderId = "Demo1002";
+        creditCard = delegator.makeValue("CreditCard", UtilMisc.toMap(
+                "cardType","CCT_VISA",
+                "expireDate","10/2011",  // mm/yyyy, gets converted to mm/yy
+                "cardNumber","4444333322221111"));
+        billingAddress = delegator.makeValue("PostalAddress", UtilMisc.toMap(
+                "toName","The customer Name",
+                "address1","The customer billingAddress1",
+                "address2","The customer billingAddress2",
+                "city","The customer city",
+                "stateProvinceGeoId", "NLD"));
+        shippingAddress = delegator.makeValue("PostalAddress", UtilMisc.toMap(
+                "toName","The customer Name",
+                "address1","The customer shippingStreet1",
+                "address2","The customer shippingStreet2",
+                "city","The customer city",
+                "stateProvinceGeoId", "NLD",
+                "postalCode","12345"));
+        orderItemMap = UtilMisc.<String, Object>toMap(
+                "orderId", "Demo1002", 
+                "orderItemSeqId", "00001", 
+                "orderItemTypeId", "PRODUCT_ORDER_ITEM", 
+                "productId", "GZ-1000",
+                "prodCatalogId", "DemoCatalog", 
+                "quantity" , new BigDecimal("2.000000"), 
+                "unitPrice", new BigDecimal("59.00"),
+                "statusId" ,"ITEM_COMPLETED"
+                );
+        orderItems = UtilMisc.<Object>toList(orderItemMap);
+        billToParty = delegator.makeValue("Party" , UtilMisc.toMap("partyId", "DemoCustomer"));
+        paymentGatewayConfigId = "SECUREPAY_CONFIG";
+        refundAmount = new BigDecimal("100.08");
+        orderPaymentPreference = delegator.makeValue("OrderPaymentPreference", UtilMisc.toMap(
+            "orderPaymentPreferenceId", "testOrder1000_01", 
+            "orderId", "Demo1002", 
+            "paymentMethodTypeId", "CREDIT_CARD", 
+            "maxAmount", new BigDecimal("200.00"), 
+            "statusId", "PAYMENT_AUTHORIZED"));
+        
+        GenericValue checkOrderPaymentPreference = EntityQuery.use(delegator).from("OrderPaymentPreference").where("orderPaymentPreferenceId", "testOrder1000_01").queryOne();
+        if (UtilValidate.isEmpty(checkOrderPaymentPreference)) {
+            orderPaymentPreference.create();
+        }
+    }
+
+    public void testAuth() throws Exception{
+        Debug.logInfo("=====[testAuth] starting....", module);
+        try {
+            Map<String, Object> serviceInput = UtilMisc.<String, Object>toMap(
+                    "paymentConfig", configFile,
+                    "billToParty", billToParty,
+                    "billToEmail", emailAddr,
+                    "orderPaymentPreference", orderPaymentPreference,
+                    "orderItems", orderItems,
+                    "creditCard", creditCard,
+                    "billingAddress", billingAddress,
+                    "shippingAddress", shippingAddress,
+                    "orderId", orderId,
+                    "currency", "AUD"
+           );
+            serviceInput.put("processAmount", new BigDecimal("100.08"));
+
+            // run the service
+            Map<String, Object> result = dispatcher.runSync("ofbScAuthorize",serviceInput);
+
+            // verify the results
+            String responseMessage = (String) result.get(ModelService.RESPONSE_MESSAGE);
+            Debug.logInfo("[testCCAuth] responseMessage: " + responseMessage, module);
+            TestCase.assertEquals("Service result is success", ModelService.RESPOND_SUCCESS, responseMessage);
+
+            if (((Boolean) result.get("authResult")).equals(new Boolean(false))) {          // returnCode ok?
+                Debug.logInfo("[testAuth] Error Messages from SecurePay: " + result.get("internalRespMsgs"), module);
+                TestCase.fail("Returned messages:" + result.get("internalRespMsgs"));
+            } else {
+                Debug.logInfo("[testAuth] Result from SecurePay: " + result, module);
+                String authRefNum = (String) result.get("authRefNum");
+                BigDecimal processAmount =  (BigDecimal) result.get("processAmount");
+                paymentGatewayResponse = delegator.makeValue("PaymentGatewayResponse" , UtilMisc.toMap(
+                        "paymentGatewayResponseId", "testOrder1000_01",
+                        "orderPaymentPreferenceId", "testOrder1000_01",
+                        "amount" , processAmount,
+                        "referenceNum", authRefNum,
+                        "paymentMethodTypeId", "CREDIT_CARD",
+                        "paymentServiceTypeEnumId", "PRDS_PAY_AUTH",
+                        "currencyUomId", "AUD"
+                        ));
+                GenericValue checkPaymentGatewayResponse = EntityQuery.use(delegator).from("PaymentGatewayResponse").where("paymentGatewayResponseId", "testOrder1000_01").queryOne();
+                if (UtilValidate.isEmpty(checkPaymentGatewayResponse)) {
+                    paymentGatewayResponse.create();
+                }
+            }
+        } catch (GenericServiceException ex) {
+            TestCase.fail(ex.getMessage());
+        }
+    }
+
+    public void testdoCapture() throws Exception {
+        Debug.logInfo("=====[testdoCapture] starting....", module);
+        GenericValue paymentGatewayResponse = EntityQuery.use(delegator).from("PaymentGatewayResponse").where("paymentGatewayResponseId", "testOrder1000_01").queryOne();
+        try {
+            Map<String, Object> serviceInput = UtilMisc.<String, Object>toMap(
+                    "paymentConfig", configFile,
+                    "orderPaymentPreference", orderPaymentPreference,
+                    "authTrans", paymentGatewayResponse
+           );
+            serviceInput.put("captureAmount", refundAmount);
+
+            // run the service
+            Map<String, Object> result = dispatcher.runSync("ofbScCapture",serviceInput);
+
+            // verify the results
+            String responseMessage = (String) result.get(ModelService.RESPONSE_MESSAGE);
+            Debug.logInfo("[testdoCapture] responseMessage: " + responseMessage, module);
+            TestCase.assertEquals("Service result is success", ModelService.RESPOND_SUCCESS, responseMessage);
+
+            if (((Boolean) result.get("captureResult")).equals(new Boolean(false))) {          // returnCode ok?
+                Debug.logInfo("[testdoCapture] Error Messages from SecurePay: " + result.get("internalRespMsgs"), module);
+                TestCase.fail("Returned messages:" + result.get("internalRespMsgs"));
+            } else {
+                String captureRefNum = (String) result.get("captureRefNum");
+                GenericValue checkPaymentGatewayResponse = EntityQuery.use(delegator).from("PaymentGatewayResponse").where("paymentGatewayResponseId", "testOrder1000_01").queryOne();
+                checkPaymentGatewayResponse.set("referenceNum", captureRefNum);
+                checkPaymentGatewayResponse.store();
+                Debug.logInfo("[testdoCapture] Result from SecurePay: " + result, module);
+            }
+            
+        } catch (GenericServiceException ex) {
+            TestCase.fail(ex.getMessage());
+        }
+    }
+
+    public void testdoRefund() throws Exception {
+        Debug.logInfo("=====[testdoRefund] starting....", module);
+        try {
+            Map<String, Object> serviceInput = UtilMisc.toMap(
+                    "paymentConfig", configFile,
+                    "orderPaymentPreference", orderPaymentPreference
+           );
+            serviceInput.put("refundAmount", refundAmount);
+            // run the service
+            Map<String, Object> result = dispatcher.runSync("ofbScRefund", serviceInput);
+
+            // verify the results
+            String responseMessage = (String) result.get(ModelService.RESPONSE_MESSAGE);
+            Debug.logInfo("[testdoRefund] responseMessage: " + responseMessage, module);
+            TestCase.assertEquals("Service result is success", ModelService.RESPOND_SUCCESS, responseMessage);
+
+            if (((Boolean) result.get("refundResult")).equals(new Boolean(false))) {          // returnCode ok?
+                Debug.logInfo("[testdoRefund] Error Messages from SecurePay: " + result.get("internalRespMsgs"), module);
+                TestCase.fail("Returned messages:" + result.get("internalRespMsgs"));
+            } else {
+                Debug.logInfo("[testdoRefund] Result from SecurePay: " + result, module);
+            }
+
+        } catch (GenericServiceException ex) {
+            TestCase.fail(ex.getMessage());
+        }
+    }
+
+    public void testdoCredit() throws Exception{
+        Debug.logInfo("=====[testdoCredit] starting....", module);
+        try {
+            Map<String, Object> serviceInput = UtilMisc.toMap(
+                    "paymentConfig", configFile,
+                    "billToParty", billToParty,
+                    "billToEmail", emailAddr,
+                    "orderItems", orderItems,
+                    "creditCard", creditCard,
+                    "billingAddress", billingAddress,
+                    "referenceCode", orderId,
+                    "currency", "AUD"
+           );
+            serviceInput.put("creditAmount", creditAmount);
+            // run the service
+            Map<String, Object> result = dispatcher.runSync("ofbScCCCredit",serviceInput);
+            // verify the results
+            String responseMessage = (String) result.get(ModelService.RESPONSE_MESSAGE);
+            Debug.logInfo("[testdoCredit] responseMessage: " + responseMessage, module);
+            TestCase.assertEquals("Service result is success", ModelService.RESPOND_SUCCESS, responseMessage);
+
+            if (((Boolean) result.get("creditResult")).equals(new Boolean(false))) {          // returnCode ok?
+                Debug.logInfo("[testdoCredit] Error Messages from SecurePay: " + result.get("internalRespMsgs"), module);
+                TestCase.fail("Returned messages:" + result.get("internalRespMsgs"));
+            } else {
+                Debug.logInfo("[testdoCredit] Result from SecurePay: " + result, module);
+            }
+
+        } catch (GenericServiceException ex) {
+            TestCase.fail(ex.getMessage());
+        }
+    }
+}

Propchange: ofbiz/trunk/applications/accounting/src/org/ofbiz/accounting/thirdparty/securepay/SecurePayServiceTest.java
            ('svn:eol-style' removed)

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java?rev=1695126&r1=1695125&r2=1695126&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java Mon Aug 10 16:15:37 2015
@@ -1,140 +1,140 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *******************************************************************************/
-package org.ofbiz.content.webapp.ftl;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.servlet.http.HttpServletRequest;
-
-import org.ofbiz.base.util.Debug;
-import org.ofbiz.base.util.GeneralException;
-import org.ofbiz.base.util.UtilHttp;
-import org.ofbiz.base.util.UtilMisc;
-import org.ofbiz.base.util.UtilValidate;
-import org.ofbiz.base.util.collections.MapStack;
-import org.ofbiz.base.util.template.FreeMarkerWorker;
-import org.ofbiz.content.content.ContentWorker;
-import org.ofbiz.entity.Delegator;
-import org.ofbiz.service.LocalDispatcher;
-
-import freemarker.core.Environment;
-import freemarker.template.TemplateTransformModel;
-
-/**
- * RenderContentAndSubContent - Freemarker Transform for Content rendering
- * This transform cannot be called recursively (at this time).
- */
-public class RenderContentAndSubContent implements TemplateTransformModel {
-
-    public static final String module = RenderContentAndSubContent.class.getName();
-//    public static final String [] upSaveKeyNames = {"globalNodeTrail"};
-//    public static final String [] saveKeyNames = {"contentId", "subContentId", "subDataResourceTypeId", "mimeTypeId", "whenMap", "locale",  "wrapTemplateId", "encloseWrapText", "nullThruDatesOnly", "globalNodeTrail"};
-
-    @SuppressWarnings("unchecked")
-    public Writer getWriter(final Writer out, Map args) {
-        final Environment env = Environment.getCurrentEnvironment();
-        final LocalDispatcher dispatcher = FreeMarkerWorker.getWrappedObject("dispatcher", env);
-        final Delegator delegator = FreeMarkerWorker.getWrappedObject("delegator", env);
-        final HttpServletRequest request = FreeMarkerWorker.getWrappedObject("request", env);
-        // final HttpServletResponse response = FreeMarkerWorker.getWrappedObject("response", env);
-        final Map<String, Object> envMap = FreeMarkerWorker.createEnvironmentMap(env);
-        final MapStack<String> templateRoot = MapStack.create();
-        ((MapStack)templateRoot).push(envMap);
-        if (Debug.verboseOn()) Debug.logVerbose("in RenderContentAndSubContent, contentId(0):" + templateRoot.get("contentId"), module);
-        FreeMarkerWorker.getSiteParameters(request, templateRoot);
-        // final Map savedValuesUp = new HashMap<String, Object>();
-        // FreeMarkerWorker.saveContextValues(templateRoot, upSaveKeyNames, savedValuesUp);
-        FreeMarkerWorker.overrideWithArgs(templateRoot, args);
-
-        // final Map<String, Object> savedValues = new HashMap<String, Object>();
-
-        return new Writer(out) {
-
-            @Override
-            public void write(char cbuf[], int off, int len) {
-            }
-
-            @Override
-            public void flush() throws IOException {
-                out.flush();
-            }
-
-            @Override
-            public void close() throws IOException {
-                renderSubContent();
-                //if (Debug.verboseOn()) Debug.logVerbose("in Render(2), globalNodeTrail ." + getWrapped(env, "globalNodeTrail") , module);
-            }
-
-            public void renderSubContent() throws IOException {
-                String mimeTypeId = (String) templateRoot.get("mimeTypeId");
-                Object localeObject = templateRoot.get("locale");
-                Locale locale = null;
-                if (localeObject == null) {
-                    locale = UtilHttp.getLocale(request);
-                } else {
-                    locale = UtilMisc.ensureLocale(localeObject);
-                }
-
-                if (Debug.verboseOn()) Debug.logVerbose("in RenderContentAndSubContent, contentId(2):" + templateRoot.get("contentId"), module);
-                if (Debug.verboseOn()) Debug.logVerbose("in RenderContentAndSubContent, subContentId(2):" + templateRoot.get("subContentId"), module);
-                //if (thisView != null) {
-                    try {
-                        String contentId = (String)templateRoot.get("contentId");
-                        String mapKey = (String)templateRoot.get("mapKey");
-                        String contentAssocTypeId = (String)templateRoot.get("contentAssocTypeId");
-                        if (UtilValidate.isNotEmpty(mapKey) || UtilValidate.isNotEmpty(contentAssocTypeId)) {
-                            String txt = ContentWorker.renderSubContentAsText(dispatcher, delegator, contentId, mapKey, templateRoot, locale, mimeTypeId, true);
-                            //String txt = ContentWorker.renderSubContentAsTextCache(delegator, thisContentId, thisMapKey, null, templateRoot, locale, mimeTypeId, null, fromDate);
-//                           if ("true".equals(xmlEscape)) {
-//                                txt = UtilFormatOut.encodeXmlValue(txt);
-//                            }
-
-                            out.write(txt);
-
-//                            if (Debug.infoOn()) Debug.logInfo("in RenderSubContent, after renderContentAsTextCache:", module);
-//                                     List assocList = null;
-//                            if (UtilValidate.isNotEmpty(contentAssocTypeId)) {
-//                                assocList = UtilMisc.toList(contentAssocTypeId);
-//                            }
-//                            GenericValue content = ContentWorker.getSubContent(delegator, contentId, mapKey, null, null, assocList, null);
-//                            if (content != null) {
-//                              contentId = content.getString("contentId");
-//                            } else {
-//                              contentId = null;
-//                            }
-                        } else if (contentId != null) {
-                            ContentWorker.renderContentAsText(dispatcher, delegator, contentId, out, templateRoot, locale, mimeTypeId, null, null, true);
-//                            ((MapStack)templateRoot).pop();
-                        }
-                        //FreeMarkerWorker.reloadValues(templateRoot, savedValues, env);
-                        //FreeMarkerWorker.reloadValues(templateRoot, savedValuesUp, env);
-
-                    } catch (GeneralException e) {
-                        String errMsg = "Error rendering thisContentId:" + (String)templateRoot.get("contentId") + " msg:" + e.toString();
-                        Debug.logError(e, errMsg, module);
-                        // just log a message and don't return anything: throw new IOException();
-                    }
-            }
-
-        };
-    }
-}
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.content.webapp.ftl;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.GeneralException;
+import org.ofbiz.base.util.UtilHttp;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.base.util.collections.MapStack;
+import org.ofbiz.base.util.template.FreeMarkerWorker;
+import org.ofbiz.content.content.ContentWorker;
+import org.ofbiz.entity.Delegator;
+import org.ofbiz.service.LocalDispatcher;
+
+import freemarker.core.Environment;
+import freemarker.template.TemplateTransformModel;
+
+/**
+ * RenderContentAndSubContent - Freemarker Transform for Content rendering
+ * This transform cannot be called recursively (at this time).
+ */
+public class RenderContentAndSubContent implements TemplateTransformModel {
+
+    public static final String module = RenderContentAndSubContent.class.getName();
+//    public static final String [] upSaveKeyNames = {"globalNodeTrail"};
+//    public static final String [] saveKeyNames = {"contentId", "subContentId", "subDataResourceTypeId", "mimeTypeId", "whenMap", "locale",  "wrapTemplateId", "encloseWrapText", "nullThruDatesOnly", "globalNodeTrail"};
+
+    @SuppressWarnings("unchecked")
+    public Writer getWriter(final Writer out, Map args) {
+        final Environment env = Environment.getCurrentEnvironment();
+        final LocalDispatcher dispatcher = FreeMarkerWorker.getWrappedObject("dispatcher", env);
+        final Delegator delegator = FreeMarkerWorker.getWrappedObject("delegator", env);
+        final HttpServletRequest request = FreeMarkerWorker.getWrappedObject("request", env);
+        // final HttpServletResponse response = FreeMarkerWorker.getWrappedObject("response", env);
+        final Map<String, Object> envMap = FreeMarkerWorker.createEnvironmentMap(env);
+        final MapStack<String> templateRoot = MapStack.create();
+        ((MapStack)templateRoot).push(envMap);
+        if (Debug.verboseOn()) Debug.logVerbose("in RenderContentAndSubContent, contentId(0):" + templateRoot.get("contentId"), module);
+        FreeMarkerWorker.getSiteParameters(request, templateRoot);
+        // final Map savedValuesUp = new HashMap<String, Object>();
+        // FreeMarkerWorker.saveContextValues(templateRoot, upSaveKeyNames, savedValuesUp);
+        FreeMarkerWorker.overrideWithArgs(templateRoot, args);
+
+        // final Map<String, Object> savedValues = new HashMap<String, Object>();
+
+        return new Writer(out) {
+
+            @Override
+            public void write(char cbuf[], int off, int len) {
+            }
+
+            @Override
+            public void flush() throws IOException {
+                out.flush();
+            }
+
+            @Override
+            public void close() throws IOException {
+                renderSubContent();
+                //if (Debug.verboseOn()) Debug.logVerbose("in Render(2), globalNodeTrail ." + getWrapped(env, "globalNodeTrail") , module);
+            }
+
+            public void renderSubContent() throws IOException {
+                String mimeTypeId = (String) templateRoot.get("mimeTypeId");
+                Object localeObject = templateRoot.get("locale");
+                Locale locale = null;
+                if (localeObject == null) {
+                    locale = UtilHttp.getLocale(request);
+                } else {
+                    locale = UtilMisc.ensureLocale(localeObject);
+                }
+
+                if (Debug.verboseOn()) Debug.logVerbose("in RenderContentAndSubContent, contentId(2):" + templateRoot.get("contentId"), module);
+                if (Debug.verboseOn()) Debug.logVerbose("in RenderContentAndSubContent, subContentId(2):" + templateRoot.get("subContentId"), module);
+                //if (thisView != null) {
+                    try {
+                        String contentId = (String)templateRoot.get("contentId");
+                        String mapKey = (String)templateRoot.get("mapKey");
+                        String contentAssocTypeId = (String)templateRoot.get("contentAssocTypeId");
+                        if (UtilValidate.isNotEmpty(mapKey) || UtilValidate.isNotEmpty(contentAssocTypeId)) {
+                            String txt = ContentWorker.renderSubContentAsText(dispatcher, delegator, contentId, mapKey, templateRoot, locale, mimeTypeId, true);
+                            //String txt = ContentWorker.renderSubContentAsTextCache(delegator, thisContentId, thisMapKey, null, templateRoot, locale, mimeTypeId, null, fromDate);
+//                           if ("true".equals(xmlEscape)) {
+//                                txt = UtilFormatOut.encodeXmlValue(txt);
+//                            }
+
+                            out.write(txt);
+
+//                            if (Debug.infoOn()) Debug.logInfo("in RenderSubContent, after renderContentAsTextCache:", module);
+//                                     List assocList = null;
+//                            if (UtilValidate.isNotEmpty(contentAssocTypeId)) {
+//                                assocList = UtilMisc.toList(contentAssocTypeId);
+//                            }
+//                            GenericValue content = ContentWorker.getSubContent(delegator, contentId, mapKey, null, null, assocList, null);
+//                            if (content != null) {
+//                              contentId = content.getString("contentId");
+//                            } else {
+//                              contentId = null;
+//                            }
+                        } else if (contentId != null) {
+                            ContentWorker.renderContentAsText(dispatcher, delegator, contentId, out, templateRoot, locale, mimeTypeId, null, null, true);
+//                            ((MapStack)templateRoot).pop();
+                        }
+                        //FreeMarkerWorker.reloadValues(templateRoot, savedValues, env);
+                        //FreeMarkerWorker.reloadValues(templateRoot, savedValuesUp, env);
+
+                    } catch (GeneralException e) {
+                        String errMsg = "Error rendering thisContentId:" + (String)templateRoot.get("contentId") + " msg:" + e.toString();
+                        Debug.logError(e, errMsg, module);
+                        // just log a message and don't return anything: throw new IOException();
+                    }
+            }
+
+        };
+    }
+}

Propchange: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentAndSubContent.java
            ('svn:eol-style' removed)

Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentTransform.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentTransform.java?rev=1695126&r1=1695125&r2=1695126&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentTransform.java (original)
+++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentTransform.java Mon Aug 10 16:15:37 2015
@@ -1,161 +1,161 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *******************************************************************************/
-package org.ofbiz.content.webapp.ftl;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.Locale;
-import java.util.Map;
-
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.ofbiz.base.util.Debug;
-import org.ofbiz.base.util.GeneralException;
-import org.ofbiz.base.util.UtilFormatOut;
-import org.ofbiz.base.util.UtilHttp;
-import org.ofbiz.base.util.UtilMisc;
-import org.ofbiz.base.util.UtilProperties;
-import org.ofbiz.base.util.UtilValidate;
-import org.ofbiz.base.util.collections.MapStack;
-import org.ofbiz.base.util.template.FreeMarkerWorker;
-import org.ofbiz.content.content.ContentWorker;
-import org.ofbiz.entity.Delegator;
-import org.ofbiz.service.LocalDispatcher;
-import org.ofbiz.webapp.control.RequestHandler;
-
-import freemarker.core.Environment;
-import freemarker.template.TemplateTransformModel;
-
-/**
- * RenderContentAsText - Freemarker Transform for Content rendering
- * This transform cannot be called recursively (at this time).
- */
-public class RenderContentTransform implements TemplateTransformModel {
-
-    public static final String module = RenderContentTransform.class.getName();
-
-    @SuppressWarnings("unchecked")
-    public Writer getWriter(final Writer out, Map args) {
-        final Environment env = Environment.getCurrentEnvironment();
-        final Delegator delegator = FreeMarkerWorker.getWrappedObject("delegator", env);
-        final LocalDispatcher dispatcher = FreeMarkerWorker.getWrappedObject("dispatcher", env);
-        final HttpServletRequest request = FreeMarkerWorker.getWrappedObject("request", env);
-        final HttpServletResponse response = FreeMarkerWorker.getWrappedObject("response", env);
-
-        final Map<String, Object> templateRoot = MapStack.create(FreeMarkerWorker.createEnvironmentMap(env));
-        ((MapStack)templateRoot).push(args);
-        final String xmlEscape =  (String)templateRoot.get("xmlEscape");
-        final String thisContentId = (String)templateRoot.get("contentId");
-
-        return new Writer(out) {
-
-            @Override
-            public void write(char cbuf[], int off, int len) {
-            }
-
-            @Override
-            public void flush() throws IOException {
-                out.flush();
-            }
-
-            @Override
-            public void close() throws IOException {
-                renderSubContent();
-            }
-
-            public void renderSubContent() throws IOException {
-                String mimeTypeId = (String) templateRoot.get("mimeTypeId");
-                Object localeObject = templateRoot.get("locale");
-                Locale locale = null;
-                if (localeObject == null) {
-                    locale = UtilHttp.getLocale(request);
-                } else {
-                    locale = UtilMisc.ensureLocale(localeObject);
-                }
-
-                String editRequestName = (String)templateRoot.get("editRequestName");
-
-                if (UtilValidate.isNotEmpty(editRequestName)) {
-                    String editStyle = getEditStyle();
-                    openEditWrap(out, editStyle);
-                }
-
-                try {
-                    String txt = null;
-
-                    String mapKey = (String)templateRoot.get("mapKey");
-                    if (UtilValidate.isEmpty(mapKey)) {
-                        txt = ContentWorker.renderContentAsText(dispatcher, delegator, thisContentId, templateRoot, locale, mimeTypeId, true);
-                    } else {
-                        txt = ContentWorker.renderSubContentAsText(dispatcher, delegator, thisContentId, mapKey, templateRoot, locale, mimeTypeId, true);
-                    }
-                    if ("true".equals(xmlEscape)) {
-                        txt = UtilFormatOut.encodeXmlValue(txt);
-                    }
-
-                    out.write(txt);
-
-                } catch (GeneralException e) {
-                    String errMsg = "Error rendering thisContentId:" + thisContentId + " msg:" + e.toString();
-                    Debug.logError(e, errMsg, module);
-                    // just log a message and don't return anything: throw new IOException();
-                }
-                if (UtilValidate.isNotEmpty(editRequestName)) {
-                    closeEditWrap(out, editRequestName);
-                }
-
-            }
-
-            public void openEditWrap(Writer out, String editStyle) throws IOException {
-                String divStr = "<div class=\"" + editStyle + "\">";
-                out.write(divStr);
-            }
-
-            public void closeEditWrap(Writer out, String editRequestName) throws IOException {
-                // StringBuilder sb = new StringBuilder();
-                String fullRequest = editRequestName;
-                String delim = "?";
-                if (UtilValidate.isNotEmpty(thisContentId)) {
-                    fullRequest += delim + "contentId=" + thisContentId;
-                    delim = "&";
-                }
-
-                out.write("<a href=\"");
-                ServletContext servletContext = request.getSession().getServletContext();
-                RequestHandler rh = (RequestHandler) servletContext.getAttribute("_REQUEST_HANDLER_");
-                out.append(rh.makeLink(request, response, "/" + fullRequest, false, false, true));
-                out.write("\">Edit</a>");
-                out.write("</div>");
-            }
-
-            public String getEditStyle() {
-                String editStyle = (String)templateRoot.get("editStyle");
-                if (UtilValidate.isEmpty(editStyle)) {
-                    editStyle = UtilProperties.getPropertyValue("content", "defaultEditStyle");
-                }
-                if (UtilValidate.isEmpty(editStyle)) {
-                    editStyle = "buttontext";
-                }
-                return editStyle;
-            }
-        };
-    }
-}
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.content.webapp.ftl;
+
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Locale;
+import java.util.Map;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.GeneralException;
+import org.ofbiz.base.util.UtilFormatOut;
+import org.ofbiz.base.util.UtilHttp;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilProperties;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.base.util.collections.MapStack;
+import org.ofbiz.base.util.template.FreeMarkerWorker;
+import org.ofbiz.content.content.ContentWorker;
+import org.ofbiz.entity.Delegator;
+import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.webapp.control.RequestHandler;
+
+import freemarker.core.Environment;
+import freemarker.template.TemplateTransformModel;
+
+/**
+ * RenderContentAsText - Freemarker Transform for Content rendering
+ * This transform cannot be called recursively (at this time).
+ */
+public class RenderContentTransform implements TemplateTransformModel {
+
+    public static final String module = RenderContentTransform.class.getName();
+
+    @SuppressWarnings("unchecked")
+    public Writer getWriter(final Writer out, Map args) {
+        final Environment env = Environment.getCurrentEnvironment();
+        final Delegator delegator = FreeMarkerWorker.getWrappedObject("delegator", env);
+        final LocalDispatcher dispatcher = FreeMarkerWorker.getWrappedObject("dispatcher", env);
+        final HttpServletRequest request = FreeMarkerWorker.getWrappedObject("request", env);
+        final HttpServletResponse response = FreeMarkerWorker.getWrappedObject("response", env);
+
+        final Map<String, Object> templateRoot = MapStack.create(FreeMarkerWorker.createEnvironmentMap(env));
+        ((MapStack)templateRoot).push(args);
+        final String xmlEscape =  (String)templateRoot.get("xmlEscape");
+        final String thisContentId = (String)templateRoot.get("contentId");
+
+        return new Writer(out) {
+
+            @Override
+            public void write(char cbuf[], int off, int len) {
+            }
+
+            @Override
+            public void flush() throws IOException {
+                out.flush();
+            }
+
+            @Override
+            public void close() throws IOException {
+                renderSubContent();
+            }
+
+            public void renderSubContent() throws IOException {
+                String mimeTypeId = (String) templateRoot.get("mimeTypeId");
+                Object localeObject = templateRoot.get("locale");
+                Locale locale = null;
+                if (localeObject == null) {
+                    locale = UtilHttp.getLocale(request);
+                } else {
+                    locale = UtilMisc.ensureLocale(localeObject);
+                }
+
+                String editRequestName = (String)templateRoot.get("editRequestName");
+
+                if (UtilValidate.isNotEmpty(editRequestName)) {
+                    String editStyle = getEditStyle();
+                    openEditWrap(out, editStyle);
+                }
+
+                try {
+                    String txt = null;
+
+                    String mapKey = (String)templateRoot.get("mapKey");
+                    if (UtilValidate.isEmpty(mapKey)) {
+                        txt = ContentWorker.renderContentAsText(dispatcher, delegator, thisContentId, templateRoot, locale, mimeTypeId, true);
+                    } else {
+                        txt = ContentWorker.renderSubContentAsText(dispatcher, delegator, thisContentId, mapKey, templateRoot, locale, mimeTypeId, true);
+                    }
+                    if ("true".equals(xmlEscape)) {
+                        txt = UtilFormatOut.encodeXmlValue(txt);
+                    }
+
+                    out.write(txt);
+
+                } catch (GeneralException e) {
+                    String errMsg = "Error rendering thisContentId:" + thisContentId + " msg:" + e.toString();
+                    Debug.logError(e, errMsg, module);
+                    // just log a message and don't return anything: throw new IOException();
+                }
+                if (UtilValidate.isNotEmpty(editRequestName)) {
+                    closeEditWrap(out, editRequestName);
+                }
+
+            }
+
+            public void openEditWrap(Writer out, String editStyle) throws IOException {
+                String divStr = "<div class=\"" + editStyle + "\">";
+                out.write(divStr);
+            }
+
+            public void closeEditWrap(Writer out, String editRequestName) throws IOException {
+                // StringBuilder sb = new StringBuilder();
+                String fullRequest = editRequestName;
+                String delim = "?";
+                if (UtilValidate.isNotEmpty(thisContentId)) {
+                    fullRequest += delim + "contentId=" + thisContentId;
+                    delim = "&";
+                }
+
+                out.write("<a href=\"");
+                ServletContext servletContext = request.getSession().getServletContext();
+                RequestHandler rh = (RequestHandler) servletContext.getAttribute("_REQUEST_HANDLER_");
+                out.append(rh.makeLink(request, response, "/" + fullRequest, false, false, true));
+                out.write("\">Edit</a>");
+                out.write("</div>");
+            }
+
+            public String getEditStyle() {
+                String editStyle = (String)templateRoot.get("editStyle");
+                if (UtilValidate.isEmpty(editStyle)) {
+                    editStyle = UtilProperties.getPropertyValue("content", "defaultEditStyle");
+                }
+                if (UtilValidate.isEmpty(editStyle)) {
+                    editStyle = "buttontext";
+                }
+                return editStyle;
+            }
+        };
+    }
+}

Propchange: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/RenderContentTransform.java
            ('svn:eol-style' removed)

Modified: ofbiz/trunk/applications/marketing/src/org/ofbiz/marketing/marketing/MarketingServices.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/marketing/src/org/ofbiz/marketing/marketing/MarketingServices.java?rev=1695126&r1=1695125&r2=1695126&view=diff
==============================================================================
--- ofbiz/trunk/applications/marketing/src/org/ofbiz/marketing/marketing/MarketingServices.java (original)
+++ ofbiz/trunk/applications/marketing/src/org/ofbiz/marketing/marketing/MarketingServices.java Mon Aug 10 16:15:37 2015
@@ -1,116 +1,116 @@
-/*******************************************************************************
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *******************************************************************************/
-package org.ofbiz.marketing.marketing;
-
-import java.sql.Timestamp;
-import java.util.Locale;
-import java.util.Map;
-
-import org.ofbiz.base.util.Debug;
-import org.ofbiz.base.util.UtilDateTime;
-import org.ofbiz.base.util.UtilMisc;
-import org.ofbiz.base.util.UtilProperties;
-import org.ofbiz.base.util.UtilValidate;
-import org.ofbiz.entity.Delegator;
-import org.ofbiz.entity.GenericEntityException;
-import org.ofbiz.entity.GenericValue;
-import org.ofbiz.entity.util.EntityQuery;
-import org.ofbiz.service.DispatchContext;
-import org.ofbiz.service.GenericServiceException;
-import org.ofbiz.service.LocalDispatcher;
-import org.ofbiz.service.ServiceUtil;
-
-/**
- * MarketingServices contains static service methods for Marketing Campaigns and Contact Lists.
- * See the documentation in marketing/servicedef/services.xml and use the service reference in
- * webtools.  Comments in this file are implemntation notes and technical details.
- */
-public class MarketingServices {
-
-    public static final String module = MarketingServices.class.getName();
-    public static final String resourceMarketing = "MarketingUiLabels";
-    public static final String resourceOrder = "OrderUiLabels";
-
-    public static Map<String, Object> signUpForContactList(DispatchContext dctx, Map<String, ? extends Object> context) {
-        LocalDispatcher dispatcher = dctx.getDispatcher();
-        Delegator delegator = dctx.getDelegator();
-        Locale locale = (Locale) context.get("locale");
-
-        Timestamp fromDate = UtilDateTime.nowTimestamp();
-        String contactListId = (String) context.get("contactListId");
-        String email = (String) context.get("email");
-        String partyId = (String) context.get("partyId");
-
-        if (!UtilValidate.isEmail(email)) {
-            String error = UtilProperties.getMessage(resourceMarketing, "MarketingCampaignInvalidEmailInput", locale);
-            return ServiceUtil.returnError(error);
-        }
-
-        try {
-            // locate the contact list
-            GenericValue contactList = EntityQuery.use(delegator).from("ContactList").where("contactListId", contactListId).queryOne();
-            if (contactList == null) {
-                String error = UtilProperties.getMessage(resourceMarketing, "MarketingContactListNotFound", UtilMisc.<String, Object>toMap("contactListId", contactListId), locale);
-                return ServiceUtil.returnError(error);
-            }
-
-            // perform actions as the system user
-            GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne();
-
-            // associate the email with anonymous user TODO: do we need a custom contact mech purpose type, say MARKETING_EMAIL?
-            if (partyId == null) {
-                // Check existing email
-                GenericValue contact = EntityQuery.use(delegator).from("PartyContactDetailByPurpose")
-                        .where("infoString", email,
-                                "contactMechTypeId", "EMAIL_ADDRESS",
-                                "contactMechPurposeTypeId", "PRIMARY_EMAIL")
-                        .orderBy("-fromDate")
-                        .filterByDate("fromDate", "thruDate", "purposeFromDate", "purposeThruDate")
-                        .queryFirst();
-                if (contact != null) {
-                    partyId = contact.getString("partyId");
-                } else {
-                    partyId = "_NA_";
-                }
-            }
-            Map<String, Object> input = UtilMisc.toMap("userLogin", userLogin, "emailAddress", email, "partyId", partyId, "fromDate", fromDate, "contactMechPurposeTypeId", "OTHER_EMAIL");
-            Map<String, Object> serviceResults = dispatcher.runSync("createPartyEmailAddress", input);
-            if (ServiceUtil.isError(serviceResults)) {
-                throw new GenericServiceException(ServiceUtil.getErrorMessage(serviceResults));
-            }
-            String contactMechId = (String) serviceResults.get("contactMechId");
-            // create a new association at this fromDate to the anonymous party with status accepted
-            input = UtilMisc.toMap("userLogin", userLogin, "contactListId", contactList.get("contactListId"),
-                    "partyId", partyId, "fromDate", fromDate, "statusId", "CLPT_PENDING", "preferredContactMechId", contactMechId, "baseLocation", context.get("baseLocation"));
-            serviceResults = dispatcher.runSync("createContactListParty", input);
-            if (ServiceUtil.isError(serviceResults)) {
-                throw new GenericServiceException(ServiceUtil.getErrorMessage(serviceResults));
-            }
-        } catch (GenericEntityException e) {
-            String error = UtilProperties.getMessage(resourceOrder, "checkhelper.problems_reading_database", locale);
-            Debug.logInfo(e, error + e.getMessage(), module);
-            return ServiceUtil.returnError(error);
-        } catch (GenericServiceException e) {
-            String error = UtilProperties.getMessage(resourceMarketing, "MarketingServiceError", locale);
-            Debug.logInfo(e, error + e.getMessage(), module);
-            return ServiceUtil.returnError(error);
-        }
-        return ServiceUtil.returnSuccess();
-    }
-}
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.marketing.marketing;
+
+import java.sql.Timestamp;
+import java.util.Locale;
+import java.util.Map;
+
+import org.ofbiz.base.util.Debug;
+import org.ofbiz.base.util.UtilDateTime;
+import org.ofbiz.base.util.UtilMisc;
+import org.ofbiz.base.util.UtilProperties;
+import org.ofbiz.base.util.UtilValidate;
+import org.ofbiz.entity.Delegator;
+import org.ofbiz.entity.GenericEntityException;
+import org.ofbiz.entity.GenericValue;
+import org.ofbiz.entity.util.EntityQuery;
+import org.ofbiz.service.DispatchContext;
+import org.ofbiz.service.GenericServiceException;
+import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.service.ServiceUtil;
+
+/**
+ * MarketingServices contains static service methods for Marketing Campaigns and Contact Lists.
+ * See the documentation in marketing/servicedef/services.xml and use the service reference in
+ * webtools.  Comments in this file are implemntation notes and technical details.
+ */
+public class MarketingServices {
+
+    public static final String module = MarketingServices.class.getName();
+    public static final String resourceMarketing = "MarketingUiLabels";
+    public static final String resourceOrder = "OrderUiLabels";
+
+    public static Map<String, Object> signUpForContactList(DispatchContext dctx, Map<String, ? extends Object> context) {
+        LocalDispatcher dispatcher = dctx.getDispatcher();
+        Delegator delegator = dctx.getDelegator();
+        Locale locale = (Locale) context.get("locale");
+
+        Timestamp fromDate = UtilDateTime.nowTimestamp();
+        String contactListId = (String) context.get("contactListId");
+        String email = (String) context.get("email");
+        String partyId = (String) context.get("partyId");
+
+        if (!UtilValidate.isEmail(email)) {
+            String error = UtilProperties.getMessage(resourceMarketing, "MarketingCampaignInvalidEmailInput", locale);
+            return ServiceUtil.returnError(error);
+        }
+
+        try {
+            // locate the contact list
+            GenericValue contactList = EntityQuery.use(delegator).from("ContactList").where("contactListId", contactListId).queryOne();
+            if (contactList == null) {
+                String error = UtilProperties.getMessage(resourceMarketing, "MarketingContactListNotFound", UtilMisc.<String, Object>toMap("contactListId", contactListId), locale);
+                return ServiceUtil.returnError(error);
+            }
+
+            // perform actions as the system user
+            GenericValue userLogin = EntityQuery.use(delegator).from("UserLogin").where("userLoginId", "system").cache().queryOne();
+
+            // associate the email with anonymous user TODO: do we need a custom contact mech purpose type, say MARKETING_EMAIL?
+            if (partyId == null) {
+                // Check existing email
+                GenericValue contact = EntityQuery.use(delegator).from("PartyContactDetailByPurpose")
+                        .where("infoString", email,
+                                "contactMechTypeId", "EMAIL_ADDRESS",
+                                "contactMechPurposeTypeId", "PRIMARY_EMAIL")
+                        .orderBy("-fromDate")
+                        .filterByDate("fromDate", "thruDate", "purposeFromDate", "purposeThruDate")
+                        .queryFirst();
+                if (contact != null) {
+                    partyId = contact.getString("partyId");
+                } else {
+                    partyId = "_NA_";
+                }
+            }
+            Map<String, Object> input = UtilMisc.toMap("userLogin", userLogin, "emailAddress", email, "partyId", partyId, "fromDate", fromDate, "contactMechPurposeTypeId", "OTHER_EMAIL");
+            Map<String, Object> serviceResults = dispatcher.runSync("createPartyEmailAddress", input);
+            if (ServiceUtil.isError(serviceResults)) {
+                throw new GenericServiceException(ServiceUtil.getErrorMessage(serviceResults));
+            }
+            String contactMechId = (String) serviceResults.get("contactMechId");
+            // create a new association at this fromDate to the anonymous party with status accepted
+            input = UtilMisc.toMap("userLogin", userLogin, "contactListId", contactList.get("contactListId"),
+                    "partyId", partyId, "fromDate", fromDate, "statusId", "CLPT_PENDING", "preferredContactMechId", contactMechId, "baseLocation", context.get("baseLocation"));
+            serviceResults = dispatcher.runSync("createContactListParty", input);
+            if (ServiceUtil.isError(serviceResults)) {
+                throw new GenericServiceException(ServiceUtil.getErrorMessage(serviceResults));
+            }
+        } catch (GenericEntityException e) {
+            String error = UtilProperties.getMessage(resourceOrder, "checkhelper.problems_reading_database", locale);
+            Debug.logInfo(e, error + e.getMessage(), module);
+            return ServiceUtil.returnError(error);
+        } catch (GenericServiceException e) {
+            String error = UtilProperties.getMessage(resourceMarketing, "MarketingServiceError", locale);
+            Debug.logInfo(e, error + e.getMessage(), module);
+            return ServiceUtil.returnError(error);
+        }
+        return ServiceUtil.returnSuccess();
+    }
+}

Propchange: ofbiz/trunk/applications/marketing/src/org/ofbiz/marketing/marketing/MarketingServices.java
            ('svn:eol-style' removed)