On 04/14/2010 04:27 PM, fmancinelli (SVN) wrote:
Author: fmancinelli
Date: 2010-04-14 16:27:12 +0200 (Wed, 14 Apr 2010)
New Revision: 28305
Modified:
platform/core/trunk/xwiki-rest/src/main/java/org/xwiki/rest/representations/objects/FormUrlEncodedObjectReader.java
platform/core/trunk/xwiki-rest/src/main/java/org/xwiki/rest/representations/objects/FormUrlEncodedPropertyReader.java
Log:
XWIKI-5109 The application/x-www-form-urlencoded reader for objects and properties is
broken.
Modified the readers in order to implement the correct behavior.
Modified:
platform/core/trunk/xwiki-rest/src/main/java/org/xwiki/rest/representations/objects/FormUrlEncodedObjectReader.java
===================================================================
---
platform/core/trunk/xwiki-rest/src/main/java/org/xwiki/rest/representations/objects/FormUrlEncodedObjectReader.java 2010-04-14
13:42:32 UTC (rev 28304)
+++
platform/core/trunk/xwiki-rest/src/main/java/org/xwiki/rest/representations/objects/FormUrlEncodedObjectReader.java 2010-04-14
14:27:12 UTC (rev 28305)
@@ -99,7 +99,7 @@
if (name.startsWith(PROPERTY_PREFIX)) {
Property property = objectFactory.createProperty();
property.setName(name.replace(PROPERTY_PREFIX, ""));
- property.setValue(httpServletRequest.getParameter(name));
+ property.setValue(form.getFirstValue(name));
object.getProperties().add(property);
}
}
Modified:
platform/core/trunk/xwiki-rest/src/main/java/org/xwiki/rest/representations/objects/FormUrlEncodedPropertyReader.java
===================================================================
---
platform/core/trunk/xwiki-rest/src/main/java/org/xwiki/rest/representations/objects/FormUrlEncodedPropertyReader.java 2010-04-14
13:42:32 UTC (rev 28304)
+++
platform/core/trunk/xwiki-rest/src/main/java/org/xwiki/rest/representations/objects/FormUrlEncodedPropertyReader.java 2010-04-14
14:27:12 UTC (rev 28305)
@@ -81,7 +81,7 @@
while (names.hasMoreElements()) {
String name = (String) names.nextElement();
if (name.startsWith(PROPERTY_PREFIX)) {
- property.setName(name);
+ property.setName(name.replace(PROPERTY_PREFIX, ""));
replace is not a good method, since it replaces from everywhere in the
string. You should use StringUtils.removeStart(name, PROPERTY_PREFIX)
property.setValue(httpServletRequest.getParameter(name));
break;
}
@@ -89,8 +89,8 @@
} else {
for (String name : form.getNames())
if (name.startsWith(PROPERTY_PREFIX)) {
- property.setName(name);
- property.setValue(httpServletRequest.getParameter(name));
+ property.setName(name.replace(PROPERTY_PREFIX, ""));
+ property.setValue(form.getFirstValue(name));
break;
}
}
--
Sergiu Dumitriu
http://purl.org/net/sergiu/