ERRest problem updating Integer attributes
Rob Urquhart <[email protected]>
| Newsgroups | gmane.comp.web.webobjects.wonder-disc |
|---|---|
| Message-ID | <[email protected]> |
I'm building an ERRest app and I'm having a problem with my updateAction() method. It works fine for String or Boolean attributes, but not for Integer attributes. When I try to update an Integer attribute my didSkipValueForKey filter delegate method gets called. My updateAction() looks like this:
ERXKeyFilter updateFilter = updateFilter();
setFilterDelegate(updateFilter);
update(maillist, updateFilter);
editingContext().saveChanges();
return response(maillist, showFilter());
updateFilter is set up like this (I put in the logging in an attempt at debugging):
private ERXKeyFilter updateFilter() {
ERXKeyFilter filter = ERXKeyFilter.filterWithAttributes();
logger.info("includes: " + filter.includes(MLMaillist.LOCAL_SENDER_POLICY));
logger.info("matches: " + filter.matches(MLMaillist.LOCAL_SENDER_POLICY, ERXKey.Type.Attribute));
return filter;
}
private void setFilterDelegate(ERXKeyFilter filter) {
filter.setDelegate(new ERXKeyFilter.Delegate() {
public void willTakeValueForKey(Object target, Object value, String key) throws SecurityException {
try {
logger.info("validating key: " + key + " value: " + value);
((MLMaillist)target).validateValueForKey(value, key);
} catch (ValidationException e) {
logger.info("Throwing SecurityException");
throw new SecurityException(e.getMessage());
}
}
public void didTakeValueForKey(Object target, Object value, String key) throws SecurityException {
logger.info("validating key: " + key + " value: " + value);
}
public void didSkipValueForKey(Object target, Object value, String key) throws SecurityException {
new RuntimeException().printStackTrace();
logger.info("validating key: " + key + " value: " + value);
}
});
}
The "localSenderPolicy" attribute has an ERXKey definition:
public static final ERXKey<Integer> LOCAL_SENDER_POLICY = new ERXKey<Integer>("localSenderPolicy");
And when I try to update it I get the following results:
[2012-07-12 16:14:33,257] INFO rest.MLMaillistRouteController.updateAction - method: PUT
[2012-07-12 16:14:33,257] INFO rest.MLMaillistRouteController.updateAction - uri: /cgi-bin/WebObjects/Maillist.woa/-60666/ra/Maillist/1239.json?sfu_token=NNQX1krpbzleYug3eDItdSqC4z49yh7vmxGIWHWw.bIHwn4Xtx2eNhr.bDGECvh5
[2012-07-12 16:14:33,257] INFO rest.MLMaillistRouteController.updateAction - request doc: {
"localSenderPolicy" : 0
}
…
[2012-07-12 16:14:33,317] INFO rest.MLMaillistRouteController.updateFilterForAdmin - includes: false
[2012-07-12 16:14:33,317] INFO rest.MLMaillistRouteController.updateFilterForAdmin - matches: true
[2012-7-12 16:14:33 PDT] <WorkerThread6> === Commit Internal Transaction
[2012-07-12 16:14:33,379] INFO rest.MLMaillistRouteController.didSkipValueForKey - validating key: localSenderPolicy value: [localSenderPolicy=0]
I'm using Wonder 5.7-SNAPSHOT, but I've tried a number of different versions and I get the same results.
Any help would be greatly appreciated!
--
Rob Urquhart
IT Services
Simon Fraser University
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/