[ofbiz-framework] branch trunk updated: Improved: Use FlexibleStringExpander for field parameter names. (OFBIZ-11330)

2020-01-29 Thread nmalin
This is an automated email from the ASF dual-hosted git repository.

nmalin pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git


The following commit(s) were added to refs/heads/trunk by this push:
 new 52e21a3  Improved: Use FlexibleStringExpander for field parameter 
names. (OFBIZ-11330)
52e21a3 is described below

commit 52e21a3d2e9123674e151d255fe898f86a5be72e
Author: Daniel Watford 
AuthorDate: Thu Jan 23 20:08:30 2020 +

Improved: Use FlexibleStringExpander for field parameter names.
(OFBIZ-11330)

Allows generation of unique names when repeating rendering of a form on a 
screen.
Added test cases to ensure parameter names can be built using 
FlexibleStringExpander.
---
 .../org/apache/ofbiz/widget/model/ModelFormField.java |  8 
 .../ofbiz/widget/model/ModelFormFieldBuilder.java |  8 
 .../apache/ofbiz/widget/model/ModelFormFieldTest.java | 19 ++-
 3 files changed, 26 insertions(+), 9 deletions(-)

diff --git 
a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java
 
b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java
index bddb033..2e4968d 100644
--- 
a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java
+++ 
b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormField.java
@@ -136,7 +136,7 @@ public class ModelFormField {
 protected final String name;
 private final List onChangeUpdateAreas;
 private final List onClickUpdateAreas;
-protected final String parameterName;
+protected final FlexibleStringExpander parameterName;
 private final Integer position;
 private final String redWhen;
 private final Boolean requiredField;
@@ -536,7 +536,7 @@ public class ModelFormField {
 return onClickUpdateAreas;
 }
 
-public String getParameterName() {
+public FlexibleStringExpander getParameterName() {
 return parameterName;
 }
 
@@ -549,7 +549,7 @@ public class ModelFormField {
 public String getParameterName(Map context) {
 String baseName;
 if (UtilValidate.isNotEmpty(this.parameterName)) {
-baseName = this.parameterName;
+baseName = this.parameterName.expandString(context);
 } else {
 baseName = this.name;
 }
@@ -1902,7 +1902,7 @@ public class ModelFormField {
 public String getParameterNameOther(Map context) {
 String baseName;
 if (UtilValidate.isNotEmpty(getModelFormField().parameterName)) {
-baseName = getModelFormField().parameterName;
+baseName = 
getModelFormField().parameterName.expandString(context);
 } else {
 baseName = getModelFormField().name;
 }
diff --git 
a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormFieldBuilder.java
 
b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormFieldBuilder.java
index 18fad7b..74f7c88 100644
--- 
a/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormFieldBuilder.java
+++ 
b/framework/widget/src/main/java/org/apache/ofbiz/widget/model/ModelFormFieldBuilder.java
@@ -90,7 +90,7 @@ public class ModelFormFieldBuilder {
 private String name = "";
 private List onChangeUpdateAreas = new ArrayList<>();
 private List onClickUpdateAreas = new ArrayList<>();
-private String parameterName = "";
+private FlexibleStringExpander parameterName = 
FlexibleStringExpander.getInstance("");
 private Integer position = null;
 private String redWhen = "";
 private Boolean requiredField = null;
@@ -172,7 +172,7 @@ public class ModelFormFieldBuilder {
 this.mapAcsr = 
FlexibleMapAccessor.getInstance(fieldElement.getAttribute("map-name"));
 this.modelForm = modelForm;
 this.name = name;
-this.parameterName = 
UtilXml.checkEmpty(fieldElement.getAttribute("parameter-name"), name);
+this.parameterName = 
FlexibleStringExpander.getInstance(UtilXml.checkEmpty(fieldElement.getAttribute("parameter-name"),
 name));
 String positionAtttr = fieldElement.getAttribute("position");
 Integer position = null;
 if (!positionAtttr.isEmpty()) {
@@ -445,7 +445,7 @@ public class ModelFormFieldBuilder {
 return onClickUpdateAreas;
 }
 
-public String getParameterName() {
+public FlexibleStringExpander getParameterName() {
 return parameterName;
 }
 
@@ -905,7 +905,7 @@ public class ModelFormFieldBuilder {
 }
 
 public ModelFormFieldBuilder setParameterName(String parameterName) {
-this.parameterName = parameterName;
+this.parameterName = FlexibleStringExpander.getInstance(parameterName);
 return this;
 }
 
diff --git 
a/framework/widget/src/test/java/org/apache/ofbiz/widget/model/ModelFormFieldTest.java
 

buildbot exception in on ofbizTrunkFrameworkPlugins

2020-01-29 Thread buildbot
The Buildbot has detected a build exception on builder 
ofbizTrunkFrameworkPlugins while building ofbiz-framework. Full details are 
available at:
https://ci.apache.org/builders/ofbizTrunkFrameworkPlugins/builds/1126

Buildbot URL: https://ci.apache.org/

Buildslave for this Build: asf946_ubuntu

Build Reason: downstream
Build Source Stamp: [branch trunk] 91fa4a958c504c8b88011ea33ba740dbd6451ca6
Blamelist: Nicolas Malin 

BUILD FAILED: exception shell_2 shell_3 upload_2

Sincerely,
 -The Buildbot





[ofbiz-framework] 02/04: Improved: Change 'restMethod' by '_method' in request parameters (OFBIZ-11332)

2020-01-29 Thread nmalin
This is an automated email from the ASF dual-hosted git repository.

nmalin pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git

commit 11cf350302015d1210b9f663cb9c68339701a3f8
Author: Nicolas Malin 
AuthorDate: Tue Jan 28 17:52:19 2020 +0100

Improved: Change 'restMethod' by '_method' in request parameters
(OFBIZ-11332)

When we analyse a request method, we currently check the parameter 
"restMethod".
Mathieu Lirzin propose [1] to use "_method" instead to use a parameter name 
more generic

I create a new function UtilHttp.getRequestMethod() to centralize the 
request method resolution.

[1] 
https://issues.apache.org/jira/browse/OFBIZ-11007?focusedCommentId=17012712=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-17012712
---
 .../src/main/java/org/apache/ofbiz/base/util/UtilHttp.java| 11 +++
 .../java/org/apache/ofbiz/webapp/control/RequestHandler.java  |  3 +--
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git 
a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java 
b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java
index f4afecd..ed8babb 100644
--- a/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java
+++ b/framework/base/src/main/java/org/apache/ofbiz/base/util/UtilHttp.java
@@ -695,6 +695,17 @@ public final class UtilHttp {
 return requestUrl.toString();
 }
 
+/** Resolve the method send with the request.
+ *  check first the parameter _method before return the request method
+ * @param request
+ * @return
+ */
+public static String getRequestMethod(HttpServletRequest request) {
+return request.getParameter("_method") != null ?
+request.getParameter("_method") :
+request.getMethod();
+}
+
 public static Locale getLocale(HttpServletRequest request, HttpSession 
session, Object appDefaultLocale) {
 // check session first, should override all if anything set there
 Object localeObject = session != null ? session.getAttribute("locale") 
: null;
diff --git 
a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java
 
b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java
index 9956de5..0e91bb1 100644
--- 
a/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java
+++ 
b/framework/webapp/src/main/java/org/apache/ofbiz/webapp/control/RequestHandler.java
@@ -260,8 +260,7 @@ public class RequestHandler {
 // The "overriddenView" attribute is set by resolveURI when necessary.
 String overrideViewUri = (String) 
request.getAttribute("overriddenView");
 
-String restMethod = request.getParameter("restMethod");
-String method = (restMethod != null) ? restMethod : 
request.getMethod();
+String method = UtilHttp.getRequestMethod(request);
 RequestMap requestMap = resolveMethod(method, rmaps).orElseThrow(() -> 
{
 String msg = UtilProperties.getMessage("WebappUiLabels", 
"RequestMethodNotMatchConfig",
 UtilMisc.toList(requestUri, method), 
UtilHttp.getLocale(request));



[ofbiz-framework] 01/04: Fixed: No functional change, correct checkstyle issues on GenericWebEvent.java

2020-01-29 Thread nmalin
This is an automated email from the ASF dual-hosted git repository.

nmalin pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git

commit fac12a4e6fbcd6892dffa2a75ed83f6bed19a424
Author: Nicolas Malin 
AuthorDate: Tue Jan 28 15:25:57 2020 +0100

Fixed: No functional change, correct checkstyle issues on 
GenericWebEvent.java
---
 .../org/apache/ofbiz/webtools/GenericWebEvent.java | 110 ++---
 1 file changed, 73 insertions(+), 37 deletions(-)

diff --git 
a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/GenericWebEvent.java
 
b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/GenericWebEvent.java
index 11e7736..07c5233 100644
--- 
a/framework/webtools/src/main/java/org/apache/ofbiz/webtools/GenericWebEvent.java
+++ 
b/framework/webtools/src/main/java/org/apache/ofbiz/webtools/GenericWebEvent.java
@@ -65,9 +65,11 @@ public class GenericWebEvent {
 entityName = (String) request.getAttribute("entityName");
 }
 if (UtilValidate.isEmpty(entityName)) {
-String errMsg = 
UtilProperties.getMessage(GenericWebEvent.err_resource, 
"genericWebEvent.entity_name_not_specified", locale) + ".";
+String errMsg = UtilProperties.getMessage(err_resource,
+"genericWebEvent.entity_name_not_specified", locale) + ".";
 request.setAttribute("_ERROR_MESSAGE_", errMsg);
-Debug.logWarning("[GenericWebEvent.updateGeneric] The entityName 
was not specified, but is required.", module);
+Debug.logWarning("[GenericWebEvent.updateGeneric] The entityName 
was not specified,"
++ " but is required.", module);
 return "error";
 }
 
@@ -75,15 +77,19 @@ public class GenericWebEvent {
 Delegator delegator = (Delegator) request.getAttribute("delegator");
 
 if (security == null) {
-String errMsg = 
UtilProperties.getMessage(GenericWebEvent.err_resource,"genericWebEvent.security_object_not_found",
 locale) + ".";
+String errMsg = UtilProperties.getMessage(err_resource,
+"genericWebEvent.security_object_not_found", locale) + ".";
 request.setAttribute("_ERROR_MESSAGE_", errMsg);
-Debug.logWarning("[updateGeneric] The security object was not 
found in the request, please check the control servlet init.", module);
+Debug.logWarning("[updateGeneric] The security object was not 
found in the request,"
++ " please check the control servlet init.", module);
 return "error";
 }
 if (delegator == null) {
-String errMsg = 
UtilProperties.getMessage(GenericWebEvent.err_resource, 
"genericWebEvent.delegator_object_not_found", locale) + ".";
+String errMsg = UtilProperties.getMessage(err_resource,
+"genericWebEvent.delegator_object_not_found", locale) + 
".";
 request.setAttribute("_ERROR_MESSAGE_", errMsg);
-Debug.logWarning("[updateGeneric] The delegator object was not 
found in the request, please check the control servlet init.", module);
+Debug.logWarning("[updateGeneric] The delegator object was not 
found in the request,"
++ " please check the control servlet init.", module);
 return "error";
 }
 
@@ -109,25 +115,33 @@ public class GenericWebEvent {
 }
 
 if (UtilValidate.isEmpty(updateMode)) {
-String errMsg = 
UtilProperties.getMessage(GenericWebEvent.err_resource, 
"genericWebEvent.update_mode_not_specified", locale) + ".";
+String errMsg = UtilProperties.getMessage(err_resource,
+"genericWebEvent.update_mode_not_specified", locale) + ".";
 request.setAttribute("_ERROR_MESSAGE_", errMsg);
-Debug.logWarning("[updateGeneric] Update Mode was not specified, 
but is required; entityName: " + entityName, module);
+Debug.logWarning("[updateGeneric] Update Mode was not specified, 
but is required;"
++ "entityName: " + entityName, module);
 return "error";
 }
 
 // check permissions before moving on...
-if (!security.hasEntityPermission("ENTITY_DATA", "_" + updateMode, 
request.getSession()) &&
-!security.hasEntityPermission(entity.getPlainTableName(), "_" + 
updateMode, request.getSession())) {
-Map messageMap = UtilMisc.toMap("updateMode", 
updateMode, "entityName", entity.getEntityName(), "entityPlainTableName", 
entity.getPlainTableName());
-String errMsg = 
UtilProperties.getMessage(GenericWebEvent.err_resource, 
"genericWebEvent.not_sufficient_permissions_01", messageMap, locale);
-errMsg += 
UtilProperties.getMessage(GenericWebEvent.err_resource, 
"genericWebEvent.not_sufficient_permissions_02", messageMap, locale) + ".";
+String plainTableName = 

[ofbiz-framework] branch trunk updated (8902637 -> 91fa4a9)

2020-01-29 Thread nmalin
This is an automated email from the ASF dual-hosted git repository.

nmalin pushed a change to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git.


from 8902637  Revert "Fixed: Potensial bug under 
CommunicationEventServices#updateCommEventAfterEmail for 
CommunicationEvent.subject field" (OFBIZ-10879)
 new fac12a4  Fixed: No functional change, correct checkstyle issues on 
GenericWebEvent.java
 new 11cf350  Improved: Change 'restMethod' by '_method' in request 
parameters (OFBIZ-11332)
 new 1ee1ec7  Fixed: Change 'restMethod' by '_method' in request parameters 
(OFBIZ-11007)
 new 91fa4a9  Fixed: Clean unecessary code and convert to groovy syntax

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/ofbiz/base/util/UtilHttp.java  |  11 +
 .../org/apache/ofbiz/entity/util/EntityUtil.java   |  53 +++
 .../ofbiz/webapp/control/RequestHandler.java   |   3 +-
 .../groovyScripts/entity/FindGeneric.groovy|  14 +-
 .../groovyScripts/entity/ViewGeneric.groovy| 409 ++---
 .../org/apache/ofbiz/webtools/GenericWebEvent.java | 133 ---
 framework/webtools/template/entity/ViewGeneric.ftl |   4 +-
 7 files changed, 279 insertions(+), 348 deletions(-)



[ofbiz-framework] 03/04: Fixed: Change 'restMethod' by '_method' in request parameters (OFBIZ-11007)

2020-01-29 Thread nmalin
This is an automated email from the ASF dual-hosted git repository.

nmalin pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git

commit 1ee1ec76d6202f66cdff271fd4c313d5d2c132cc
Author: Nicolas Malin 
AuthorDate: Tue Jan 28 18:16:13 2020 +0100

Fixed: Change 'restMethod' by '_method' in request parameters
(OFBIZ-11007)

Some issue has been introduce on the previous commit 6e1c7b5 [1], corrected 
by this one :
  * the view link on ListGeneric failed
  * the paginate on ListGeneric failed

I also simplify the url writing with delegate the entity path generation 
and translation
to two function on EntityUtil : entityToPath and getPkValuesMapFromPath

thanks to Pawan Verma to spot the pagination problem

[1] https://gitbox.apache.org/repos/asf?p=ofbiz-framework.git;h=6e1c7b5
---
 .../org/apache/ofbiz/entity/util/EntityUtil.java   | 53 ++
 .../groovyScripts/entity/FindGeneric.groovy| 14 ++
 .../groovyScripts/entity/ViewGeneric.groovy| 35 +-
 .../org/apache/ofbiz/webtools/GenericWebEvent.java | 23 +++---
 framework/webtools/template/entity/ViewGeneric.ftl |  4 +-
 5 files changed, 87 insertions(+), 42 deletions(-)

diff --git 
a/framework/entity/src/main/java/org/apache/ofbiz/entity/util/EntityUtil.java 
b/framework/entity/src/main/java/org/apache/ofbiz/entity/util/EntityUtil.java
index 0c0411d..9a69955 100644
--- 
a/framework/entity/src/main/java/org/apache/ofbiz/entity/util/EntityUtil.java
+++ 
b/framework/entity/src/main/java/org/apache/ofbiz/entity/util/EntityUtil.java
@@ -22,6 +22,7 @@ package org.apache.ofbiz.entity.util;
 import java.io.Serializable;
 import java.sql.Timestamp;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.HashMap;
@@ -48,6 +49,7 @@ import org.apache.ofbiz.entity.GenericValue;
 import org.apache.ofbiz.entity.condition.EntityCondition;
 import org.apache.ofbiz.entity.condition.EntityDateFilterCondition;
 import org.apache.ofbiz.entity.condition.OrderByList;
+import org.apache.ofbiz.entity.model.ModelEntity;
 import org.apache.ofbiz.entity.model.ModelField;
 
 import static java.util.stream.Collectors.toList;
@@ -544,4 +546,55 @@ public final class EntityUtil {
 return new PagedList<>(startIndex, endIndex, size, viewIndex, 
viewSize, dataItems);
 }
 
+/**
+ * For a entityName return the primary keys path that identify it
+ * like entityName/pkValue1/pkValue2/../pkValueN
+ * @param delegator
+ * @param entityName
+ * @param context
+ * @return
+ */
+public static String entityToPath(Delegator delegator, String entityName, 
Map context) {
+return entityToPath(delegator.makeValidValue(entityName, context));
+}
+/**
+ * For a entityName return the primary keys path that identify it
+ * like entityName/pkValue1/pkValue2/../pkValueN
+ * @param gv
+ * @return
+ */
+public static String entityToPath(GenericValue gv) {
+StringBuilder path = new StringBuilder(gv.getEntityName());
+for (String pkName : gv.getModelEntity().getPkFieldNames()) {
+path.append("/").append(gv.getString(pkName));
+}
+return path.toString();
+}
+
+/**
+ * Form a entityName and primary keys path
+ * convert it to a Map contains all pkValue :
+ *  entityName/pkValue1/pkValue2/../pkValueN
+ *-> [pkName1: pkValue1,
+ *pkName2, pkValue2,
+ *...,
+ *pkNameN: pkValueN]
+ * @param modelEntity
+ * @param path
+ * @return
+ */
+public static Map getPkValuesMapFromPath(ModelEntity 
modelEntity, String path)
+throws GenericEntityException {
+if (UtilValidate.isEmpty(path)) return null;
+LinkedList pkValues = new 
LinkedList<>(Arrays.asList(path.split("/")));
+List pkFieldNames = modelEntity.getPkFieldNames();
+if (pkFieldNames.size() != pkValues.size()) {
+throw new GenericEntityException ("Identification path failed ");
+}
+Map pkValuesMap = new HashMap<>();
+for (String pkName : modelEntity.getPkFieldNames()) {
+pkValuesMap.put(pkName, pkValues.removeFirst());
+}
+return pkValuesMap;
+}
 }
diff --git a/framework/webtools/groovyScripts/entity/FindGeneric.groovy 
b/framework/webtools/groovyScripts/entity/FindGeneric.groovy
index 29d3eb1..cd8d06a 100644
--- a/framework/webtools/groovyScripts/entity/FindGeneric.groovy
+++ b/framework/webtools/groovyScripts/entity/FindGeneric.groovy
@@ -43,7 +43,7 @@ if (modelEntity) {
 String dynamicAutoEntityFieldSearchForm = """http://www.w3.org/2001/XMLSchema-instance; 
xmlns="http://ofbiz.apache.org/Widget-Form; 
xsi:schemaLocation="http://ofbiz.apache.org/Widget-Form 
http://ofbiz.apache.org/dtds/widget-form.xsd;>
 
   

[ofbiz-framework] 04/04: Fixed: Clean unecessary code and convert to groovy syntax

2020-01-29 Thread nmalin
This is an automated email from the ASF dual-hosted git repository.

nmalin pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ofbiz-framework.git

commit 91fa4a958c504c8b88011ea33ba740dbd6451ca6
Author: Nicolas Malin 
AuthorDate: Wed Jan 29 10:47:25 2020 +0100

Fixed: Clean unecessary code and convert to groovy syntax

No functional change

The code present on ViewGeneric.groovy has been migrated from bsh script
without deep rewrite.

I removed all unecessary or redund code to lighten the reading
---
 .../groovyScripts/entity/ViewGeneric.groovy| 378 ++---
 1 file changed, 109 insertions(+), 269 deletions(-)

diff --git a/framework/webtools/groovyScripts/entity/ViewGeneric.groovy 
b/framework/webtools/groovyScripts/entity/ViewGeneric.groovy
index 79ef1fd..44de1d6 100644
--- a/framework/webtools/groovyScripts/entity/ViewGeneric.groovy
+++ b/framework/webtools/groovyScripts/entity/ViewGeneric.groovy
@@ -25,20 +25,18 @@ import org.apache.ofbiz.entity.model.ModelField
 import org.apache.ofbiz.entity.model.ModelFieldType
 import org.apache.ofbiz.entity.model.ModelRelation
 import org.apache.ofbiz.entity.model.ModelKeyMap
+import org.apache.ofbiz.base.util.StringUtil
 import org.apache.ofbiz.base.util.UtilFormatOut
 import org.apache.ofbiz.base.util.UtilMisc
-import java.sql.Timestamp
-import java.sql.Date
-import java.sql.Time
 
-String entityName = parameters.get("entityName")
-context.put("entityName", entityName)
+String entityName = parameters.entityName
+context.entityName = entityName
 
 ModelReader reader = delegator.getModelReader()
 ModelEntity entity = reader.getModelEntity(entityName)
 
-context.put("entity", entity)
-context.put("plainTableName", entity.getPlainTableName())
+context.entity = entity
+context.plainTableName = entity.getPlainTableName()
 
 boolean hasAllView = security.hasEntityPermission("ENTITY_DATA", "_VIEW", 
session)
 boolean hasAllCreate = security.hasEntityPermission("ENTITY_DATA", "_CREATE", 
session)
@@ -49,94 +47,65 @@ boolean hasCreatePermission = hasAllCreate || 
security.hasEntityPermission(entit
 boolean hasUpdatePermission = hasAllUpdate || 
security.hasEntityPermission(entity.getPlainTableName(), "_UPDATE", session)
 boolean hasDeletePermission = hasAllDelete || 
security.hasEntityPermission(entity.getPlainTableName(), "_DELETE", session)
 
-context.put("hasAllView", hasAllView)
-context.put("hasAllCreate", hasAllCreate)
-context.put("hasAllUpdate", hasAllUpdate)
-context.put("hasAllDelete", hasAllDelete)
-context.put("hasViewPermission", hasViewPermission)
-context.put("hasCreatePermission", hasCreatePermission)
-context.put("hasUpdatePermission", hasUpdatePermission)
+context.hasAllView = hasAllView
+context.hasAllCreate = hasAllCreate
+context.hasAllUpdate = hasAllUpdate
+context.hasAllDelete = hasAllDelete
+context.hasViewPermission = hasViewPermission
+context.hasCreatePermission = hasCreatePermission
+context.hasUpdatePermission = hasUpdatePermission
 context.hasDeletePermission = hasDeletePermission
 
-boolean useValue = true
 
+// Resolve and prepare pkValues from request to support rest or oldest request 
call
+Map pkNamesValuesMap = null
 if (parameters.pkValues) {
-Map pkNamesValuesMap = EntityUtil.getPkValuesMapFromPath(
+pkNamesValuesMap = EntityUtil.getPkValuesMapFromPath(
 delegator.getModelEntity(entityName), parameters.pkValues)
 parameters << pkNamesValuesMap
-context.pkNamesValuesMap = pkNamesValuesMap
 }
 GenericValue valueFromParameters = delegator.makeValue(entityName)
 valueFromParameters.setPKFields(parameters)
 GenericPK findByPK = valueFromParameters.getPrimaryKey()
 context.currentFindString = 
UtilFormatOut.encodeQuery(EntityUtil.entityToPath(valueFromParameters))
-context.put("findByPk", findByPK.toString())
+context.findByPk = findByPK.toString()
+context.pkNamesValuesMap = pkNamesValuesMap ?: 
valueFromParameters.getPrimaryKey().getAllFields()
 
 GenericValue value = null
 //only try to find it if this is a valid primary key...
 if (findByPK.isPrimaryKey()) {
-value = from(findByPK.getEntityName()).where(findByPK).queryOne();
+value = from(findByPK.getEntityName()).where(findByPK).queryOne()
 }
-context.put("value", value)
+context.value = value
 
-if (value == null) {
-useValue = false
-}
+boolean useValue = value != null
 
-if (value != null) {
+if (value) {
 List fieldList = []
 Iterator fieldIterator = entity.getFieldsIterator()
 while (fieldIterator.hasNext()) {
 Map mapField = [:]
 
 ModelField field = fieldIterator.next()
-ModelFieldType type = delegator.getEntityFieldType(entity, 
field.getType())
-
-String fieldValue = ""
-if ("Timestamp".equals(type.getJavaType()) || 
"java.sql.Timestamp".equals(type.getJavaType())) {
-Timestamp dtVal = value.getTimestamp(field.getName())
-fieldValue = (dtVal == null) ? "" : dtVal.toString()
-