Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-2170

Problem with saving multi-value property using REST 3.x

    Details

    • Steps to Reproduce:
      Hide

      1. Create a node which contains single multi-valued unstructured property using POST method.
      2. Try to update that value (without adding any others) using PUT method.

      Show
      1. Create a node which contains single multi-valued unstructured property using POST method. 2. Try to update that value (without adding any others) using PUT method.

      Description

      I would like to report you a bug related to saving node values using REST Service 3.x.
      When you try to save single value unstructured property, which is multi-valued inside, for example: each single property contains of a set of key - value properties, which could look like that:

      "tag:tagname": [
          "{"name":"firstname","type":"firsttype","value":"firstvalue"}"
        ]
      

      the exception is thrown. It says multi-valued property cannot be save using single-valued setter methods.
      First try of saving such value doesn't cause error, but when you try to save it, the error appears. It is caused by following code from ItemHandler class, setPropertyOnNode method:

      	Value[] values = convertToJcrValues(node, value, encoded);
      	if (values.length == 0) {
                  // remove the property
                  node.setProperty(propName, (Value[])null);
              } else if (values.length == 1) {
                  node.setProperty(propName, values[0]);
              } else {
                  node.setProperty(propName, values);
              }
      

      Calling setProperty method, application doesn't check if the property is multi-valued inside, it checkes only the number of values in the array.

      Below you can see StackTrace.

      WARN  2014-03-12 08:26:04.865 javax.jcr.ValueFormatException: Unable to set existing multi-valued property "mswf:fields" on node "/nodename/3.bmp" in workspace "default" using single-value setter methods
      	at org.modeshape.jcr.AbstractJcrNode.setProperty(AbstractJcrNode.java:1727)
      	at org.modeshape.jcr.AbstractJcrNode.setProperty(AbstractJcrNode.java:1442)
      	at org.modeshape.jcr.AbstractJcrNode.setProperty(AbstractJcrNode.java:108)
      	at org.modeshape.web.jcr.rest.handler.ItemHandler.setPropertyOnNode(ItemHandler.java:413)
      	at org.modeshape.web.jcr.rest.handler.ItemHandler.updateNode(ItemHandler.java:646)
      	at org.modeshape.web.jcr.rest.handler.ItemHandler.updateNode(ItemHandler.java:588)
      	at org.modeshape.web.jcr.rest.handler.ItemHandler.updateItem(ItemHandler.java:570)
      	at org.modeshape.web.jcr.rest.handler.RestItemHandler.updateItem(RestItemHandler.java:161)
      	at org.modeshape.web.jcr.rest.ModeShapeRestService.putItem(ModeShapeRestService.java:450)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:606)
      	at org.jboss.resteasy.core.MethodInjectorImpl.invoke(MethodInjectorImpl.java:167)
      	at org.jboss.resteasy.core.ResourceMethod.invokeOnTarget(ResourceMethod.java:269)
      	at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:227)
      	at org.jboss.resteasy.core.ResourceMethod.invoke(ResourceMethod.java:216)
      	at org.jboss.resteasy.core.SynchronousDispatcher.getResponse(SynchronousDispatcher.java:542)
      	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:524)
      	at org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:126)
      	at org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)
      	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)
      	at org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)
      	at javax.servlet.http.HttpServlet.service(HttpServlet.java:728)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:305)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
      	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)
      	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
      	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:222)
      	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:123)
      	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:502)
      	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:171)
      	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
      	at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:953)
      	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
      	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:408)
      	at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1041)
      	at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:603)
      	at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:312)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
      	at java.lang.Thread.run(Thread.java:744)
      

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                hchiorean Horia Chiorean
                Reporter:
                lgadomer Lukasz Gadomer
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: