Re: [Dev] Fault String Returned Instead of the Filtered Content
Looping in Jayanga. On Tue, Oct 7, 2014 at 6:03 AM, Rajith Vitharana raji...@wso2.com wrote: Hi Shameera, Since I'm in dev service, didn't have much time to work on this. I have created unit test cases for this scenario and attached the new diff. Thanks, On Mon, Sep 29, 2014 at 7:16 AM, Shameera Rathnayaka shameerai...@gmail.com wrote: Hi Rajith, Unfortunately, for me there is no way to test above patch, if you could attach a patch for current axis2 trunk then I can have a look. I tried with the attached patch with axis2 trunk it gave me conflicts. And it is good to add an integration test to cover this improvement then we won't break this in future. Regards, Shameera. On Mon, Sep 29, 2014 at 12:11 AM, Rajith Vitharana raji...@wso2.com wrote: ping On Tue, Sep 23, 2014 at 3:12 PM, Rajith Vitharana raji...@wso2.com wrote: Hi All, Regarding the jira [1]. In DSS when using json output mapping we can filter out the output fields according to the person's role who invokes the service. If he have permission, those fields will be visible to them. If he doesn't have permission, only other fields will be visible to him. This is explained in [2] But as the jira says, this feature doesn't work in standalone pack. In wsdl file of the data service, these fields are marked as optional by adding 'minOccurs=0' attribute. But the GsonXMLStreamWriter.java class in axis2-json module doesn't consider this minOccurs attribute when converting the xml output to json. This causes the error mentioned in the jira [1]. I have changed the source to avoid this situation and consider the minOccurs attribute when doing the conversion part. Is this the better way of resolving this problem? If so please review the code and commit to kernel patch 009. [1] - https://wso2.org/jira/browse/DS-963 [2] - https://docs.wso2.com/display/DSS321/JSON+Mapping Thanks -- Rajith Vitharana Software Engineer, WSO2 Inc. : wso2.com Mobile : +94715883223 Blog : http://lankavitharana.blogspot.com/ -- Rajith Vitharana Software Engineer, WSO2 Inc. : wso2.com Mobile : +94715883223 Blog : http://lankavitharana.blogspot.com/ -- Best Regards, Shameera Rathnayaka. email: shameera AT apache.org , shameerainfo AT gmail.com Blog : http://shameerarathnayaka.blogspot.com/ -- Rajith Vitharana Software Engineer, WSO2 Inc. : wso2.com Mobile : +94715883223 Blog : http://lankavitharana.blogspot.com/ -- Sameera Jayasoma, Software Architect, WSO2, Inc. (http://wso2.com) email: same...@wso2.com blog: http://sameera.adahas.org twitter: https://twitter.com/sameerajayasoma flickr: http://www.flickr.com/photos/sameera-jayasoma/collections Mobile: 0094776364456 Lean . Enterprise . Middleware ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev
Re: [Dev] Fault String Returned Instead of the Filtered Content
Hi Shameera, Since I'm in dev service, didn't have much time to work on this. I have created unit test cases for this scenario and attached the new diff. Thanks, On Mon, Sep 29, 2014 at 7:16 AM, Shameera Rathnayaka shameerai...@gmail.com wrote: Hi Rajith, Unfortunately, for me there is no way to test above patch, if you could attach a patch for current axis2 trunk then I can have a look. I tried with the attached patch with axis2 trunk it gave me conflicts. And it is good to add an integration test to cover this improvement then we won't break this in future. Regards, Shameera. On Mon, Sep 29, 2014 at 12:11 AM, Rajith Vitharana raji...@wso2.com wrote: ping On Tue, Sep 23, 2014 at 3:12 PM, Rajith Vitharana raji...@wso2.com wrote: Hi All, Regarding the jira [1]. In DSS when using json output mapping we can filter out the output fields according to the person's role who invokes the service. If he have permission, those fields will be visible to them. If he doesn't have permission, only other fields will be visible to him. This is explained in [2] But as the jira says, this feature doesn't work in standalone pack. In wsdl file of the data service, these fields are marked as optional by adding 'minOccurs=0' attribute. But the GsonXMLStreamWriter.java class in axis2-json module doesn't consider this minOccurs attribute when converting the xml output to json. This causes the error mentioned in the jira [1]. I have changed the source to avoid this situation and consider the minOccurs attribute when doing the conversion part. Is this the better way of resolving this problem? If so please review the code and commit to kernel patch 009. [1] - https://wso2.org/jira/browse/DS-963 [2] - https://docs.wso2.com/display/DSS321/JSON+Mapping Thanks -- Rajith Vitharana Software Engineer, WSO2 Inc. : wso2.com Mobile : +94715883223 Blog : http://lankavitharana.blogspot.com/ -- Rajith Vitharana Software Engineer, WSO2 Inc. : wso2.com Mobile : +94715883223 Blog : http://lankavitharana.blogspot.com/ -- Best Regards, Shameera Rathnayaka. email: shameera AT apache.org , shameerainfo AT gmail.com Blog : http://shameerarathnayaka.blogspot.com/ -- Rajith Vitharana Software Engineer, WSO2 Inc. : wso2.com Mobile : +94715883223 Blog : http://lankavitharana.blogspot.com/ Index: src/org/apache/axis2/json/gson/GsonXMLStreamWriter.java === --- src/org/apache/axis2/json/gson/GsonXMLStreamWriter.java (revision 207992) +++ src/org/apache/axis2/json/gson/GsonXMLStreamWriter.java (working copy) @@ -131,7 +131,11 @@ private void writeStartJson(JsonObject jsonObject) throws IOException { if (jsonObject.getType() == JSONType.OBJECT) { -jsonWriter.name(jsonObject.getName()); +try { +jsonWriter.name(jsonObject.getName()); +} catch (Exception e) { +e.printStackTrace(); +} } else if (jsonObject.getType() == JSONType.ARRAY) { jsonWriter.name(jsonObject.getName()); jsonWriter.beginArray(); @@ -208,6 +212,11 @@ if (miniStack.isEmpty()) { if (!queue.isEmpty()) { JsonObject queObj = queue.peek(); +if (!queObj.getName().equals(localName) queObj.getMinOccurs() == 0 + (stack.isEmpty() || !stack.peek().getName().equals(localName))){ +queue.poll(); +queObj = queue.peek(); +} if (queObj.getName().equals(localName)) { if (flushObject != null) { if (topNestedArrayObj != null flushObject.getType() == JSONType.NESTED_ARRAY Index: src/org/apache/axis2/json/gson/factory/JsonObject.java === --- src/org/apache/axis2/json/gson/factory/JsonObject.java (revision 207992) +++ src/org/apache/axis2/json/gson/factory/JsonObject.java (working copy) @@ -25,6 +25,7 @@ private JSONType type; private String valueType; private String namespaceUri; +private long minOccurs; public JsonObject(String name, JSONType type, String valueType , String namespaceUri) { this.name = name; @@ -48,4 +49,12 @@ public String getNamespaceUri() { return namespaceUri; } + +public void setMinOccurs(long minOccurs) { +this.minOccurs = minOccurs; +} + +public long getMinOccurs() { +return minOccurs; +} } Index: src/org/apache/axis2/json/gson/factory/XmlNode.java === --- src/org/apache/axis2/json/gson/factory/XmlNode.java (revision 207992) +++ src/org/apache/axis2/json/gson/factory/XmlNode.java (working copy) @@ -30,6 +30,7 @@ private ListXmlNode childrenList
Re: [Dev] Fault String Returned Instead of the Filtered Content
ping On Tue, Sep 23, 2014 at 3:12 PM, Rajith Vitharana raji...@wso2.com wrote: Hi All, Regarding the jira [1]. In DSS when using json output mapping we can filter out the output fields according to the person's role who invokes the service. If he have permission, those fields will be visible to them. If he doesn't have permission, only other fields will be visible to him. This is explained in [2] But as the jira says, this feature doesn't work in standalone pack. In wsdl file of the data service, these fields are marked as optional by adding 'minOccurs=0' attribute. But the GsonXMLStreamWriter.java class in axis2-json module doesn't consider this minOccurs attribute when converting the xml output to json. This causes the error mentioned in the jira [1]. I have changed the source to avoid this situation and consider the minOccurs attribute when doing the conversion part. Is this the better way of resolving this problem? If so please review the code and commit to kernel patch 009. [1] - https://wso2.org/jira/browse/DS-963 [2] - https://docs.wso2.com/display/DSS321/JSON+Mapping Thanks -- Rajith Vitharana Software Engineer, WSO2 Inc. : wso2.com Mobile : +94715883223 Blog : http://lankavitharana.blogspot.com/ -- Rajith Vitharana Software Engineer, WSO2 Inc. : wso2.com Mobile : +94715883223 Blog : http://lankavitharana.blogspot.com/ ___ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev