cancel
Showing results for 
Search instead for 
Did you mean: 

Issue: not possible to update WCM item with formatted file

zmicer
Champ in-the-making
Champ in-the-making
Hi, All.

The issue is reproduced at the build of alfresco community for 24-Nov-2008
(http://dev.alfresco.com/downloads/nightly/dist/)

The case is:
A. create web form, add it to project, then create xml file using web forms section of project.
B then view content of this xml, copy it to disk, re-format it at favorite editor (\t,\n,\r added depending on os and editor)
C. at WCM click "update" button and then try to edit this xml.

Something like that appears

Caused by: java.lang.NullPointerException
at org.chiba.xml.xforms.core.Validator.checkDatatype(Validator.java:351)
at org.chiba.xml.xforms.core.Validator.validate(Validator.java:317)
at org.chiba.xml.xforms.core.Validator.validate(Validator.java:280)
at org.chiba.xml.xforms.core.Validator.validate(Validator.java:259)
at org.chiba.xml.xforms.core.Model.revalidate(Model.java:812)
at org.chiba.xml.xforms.core.Model.performDefault(Model.java:911)
at org.chiba.xml.events.impl.DefaultXMLEventService.dispatch(DefaultXMLEventService.java:286)
at org.chiba.xml.xforms.Container.dispatch(Container.java:481)
… 64 more

I have applied the following fix at the chiba sources (seems to be it could be done in other way - to remove thus values \t\r\n when performing update operation - but that is for alfresco developers to think over it). For now just think it could be useful.

/src/org/chiba/xml/xforms/core/Validator.java#public void validate(ModelItem modelItem)

Appropriate code in this method contained before the fix

        if (modelItem.isXSINillable() && (value == null || value.length() == 0)) {

and for our element this was not true, as it had values like "\n\t\t\t". For now this check contains

        if (modelItem.isXSINillable() && (value == null || value.length() == 0) || isTabbed(modelItem.getNode(), value)) {

and function for check is added

    public static final String TABS_LINE_ENDING_FILTER = "^[\\t\\n\\r]+$";
    public static boolean isTabbed(final Object node, final String value) {
        // only for elements
        if (node instanceof Element) {
            if (value.matches(TABS_LINE_ENDING_FILTER)) {
                return true;
            }
        }
        return false;
    }
1 REPLY 1

mhanisch
Champ in-the-making
Champ in-the-making
Could you open a new bug report in JIRA and post the link here?
Then me and others interested in getting this fixed could vote on the ticket and maybe create a patch…

Thanks!

Cheers,
  Michael.