[jira] [Commented] (SLING-7934) Add the ability for a resource to adapt to a JSONObject

2018-11-15 Thread Carsten Ziegeler (JIRA)


[ 
https://issues.apache.org/jira/browse/SLING-7934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16688184#comment-16688184
 ] 

Carsten Ziegeler commented on SLING-7934:
-

Pretty cool idea +1

> Add the ability for a resource to adapt to a JSONObject
> ---
>
> Key: SLING-7934
> URL: https://issues.apache.org/jira/browse/SLING-7934
> Project: Sling
>  Issue Type: Improvement
>Reporter: Jason E Bailey
>Assignee: Jason E Bailey
>Priority: Major
>
> There are multiple implementations all doing the same process of converting a 
> resource to a JSONObject. If it's that common we should just add the ability 
> to adapt the resource and centralize the implementation so that it's 
> consistent.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SLING-7934) Add the ability for a resource to adapt to a JSONObject

2018-11-15 Thread Jason E Bailey (JIRA)


[ 
https://issues.apache.org/jira/browse/SLING-7934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16688051#comment-16688051
 ] 

Jason E Bailey commented on SLING-7934:
---

By converting the get(string,class) method to a default method in the 
interface? One that uses the converter. Then we modify the implementations 
where we can to use the default method. We couldn't stop people overwriting 
that but it becomes less likely.

> Add the ability for a resource to adapt to a JSONObject
> ---
>
> Key: SLING-7934
> URL: https://issues.apache.org/jira/browse/SLING-7934
> Project: Sling
>  Issue Type: Improvement
>Reporter: Jason E Bailey
>Assignee: Jason E Bailey
>Priority: Major
>
> There are multiple implementations all doing the same process of converting a 
> resource to a JSONObject. If it's that common we should just add the ability 
> to adapt the resource and centralize the implementation so that it's 
> consistent.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SLING-7934) Add the ability for a resource to adapt to a JSONObject

2018-11-14 Thread Carsten Ziegeler (JIRA)


[ 
https://issues.apache.org/jira/browse/SLING-7934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16687562#comment-16687562
 ] 

Carsten Ziegeler commented on SLING-7934:
-

Yes, right, so the get(myKey, JsonValue.class) is the more sophisticated 
version of my getJSONType :)
I think it would be great if we would also leverage the converter in here (see 
SLING-7800).
The problematic part is in how far we can or want to enforce the support for 
this conversion on all resources?  ValueMap is just an interface

> Add the ability for a resource to adapt to a JSONObject
> ---
>
> Key: SLING-7934
> URL: https://issues.apache.org/jira/browse/SLING-7934
> Project: Sling
>  Issue Type: Improvement
>Reporter: Jason E Bailey
>Assignee: Jason E Bailey
>Priority: Major
>
> There are multiple implementations all doing the same process of converting a 
> resource to a JSONObject. If it's that common we should just add the ability 
> to adapt the resource and centralize the implementation so that it's 
> consistent.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SLING-7934) Add the ability for a resource to adapt to a JSONObject

2018-11-14 Thread Jason E Bailey (JIRA)


[ 
https://issues.apache.org/jira/browse/SLING-7934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16686926#comment-16686926
 ] 

Jason E Bailey commented on SLING-7934:
---

I tend to have long conversations in my head and then come out with a statement 
that has a fully reasoned path that no one else follows. That's relevant here 
and I'm working on it. I wouldn't go with the .getJSONType() Because it's too 
specific to JSON and there's a part of me that bulks at doing a double lookup 
in a map, one to find the object and then another to get it's type. The problem 
comes back to is that a Map is really wider then what we use or 
need. From a resource perspective the value is either a String, Number, 
Boolean, or an Instant/Calendar object with array support. 

So my own stupid proposal would be, that if I had to change the ValueMap object 
I would rather change it to a Map which most people would 
never notice, because they are requesting a specific class type when they do 
their get. The change, however, would be really useful to anyone who needs to 
introspect the value type during processing.

You could then do things such as 
ResourceValue.isArray()
ResourceValue.getType() <- prefer an enum here
ResourceValue.getOriginalType()
ResourceValue.getValue()

 

Though that could be implemented as part of existing interface as a supported 
type that internal conversions handle. meaning that it stays  but 
you could just do a .get(mykey, ResourceValue.class). Of course now I just 
typed all of this and I just had this moment of "woah" cause we could probably 
do .get(myKey,JsonValue.class) as well and then you would have to go through 
half the work that you otherwise would need to,.

 

> Add the ability for a resource to adapt to a JSONObject
> ---
>
> Key: SLING-7934
> URL: https://issues.apache.org/jira/browse/SLING-7934
> Project: Sling
>  Issue Type: Improvement
>Reporter: Jason E Bailey
>Assignee: Jason E Bailey
>Priority: Major
>
> There are multiple implementations all doing the same process of converting a 
> resource to a JSONObject. If it's that common we should just add the ability 
> to adapt the resource and centralize the implementation so that it's 
> consistent.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SLING-7934) Add the ability for a resource to adapt to a JSONObject

2018-11-14 Thread Carsten Ziegeler (JIRA)


[ 
https://issues.apache.org/jira/browse/SLING-7934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16686644#comment-16686644
 ] 

Carsten Ziegeler commented on SLING-7934:
-

[~karlpauls] afaik there is no support to convert something to json, we could 
provide such a converter rule. 

> Add the ability for a resource to adapt to a JSONObject
> ---
>
> Key: SLING-7934
> URL: https://issues.apache.org/jira/browse/SLING-7934
> Project: Sling
>  Issue Type: Improvement
>Reporter: Jason E Bailey
>Assignee: Jason E Bailey
>Priority: Major
>
> There are multiple implementations all doing the same process of converting a 
> resource to a JSONObject. If it's that common we should just add the ability 
> to adapt the resource and centralize the implementation so that it's 
> consistent.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SLING-7934) Add the ability for a resource to adapt to a JSONObject

2018-11-14 Thread Karl Pauls (JIRA)


[ 
https://issues.apache.org/jira/browse/SLING-7934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16686627#comment-16686627
 ] 

Karl Pauls commented on SLING-7934:
---

[~cziegeler], stupid question but couldn't the convert stuff from osgi be 
helpful in these cases?

> Add the ability for a resource to adapt to a JSONObject
> ---
>
> Key: SLING-7934
> URL: https://issues.apache.org/jira/browse/SLING-7934
> Project: Sling
>  Issue Type: Improvement
>Reporter: Jason E Bailey
>Assignee: Jason E Bailey
>Priority: Major
>
> There are multiple implementations all doing the same process of converting a 
> resource to a JSONObject. If it's that common we should just add the ability 
> to adapt the resource and centralize the implementation so that it's 
> consistent.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SLING-7934) Add the ability for a resource to adapt to a JSONObject

2018-11-14 Thread Carsten Ziegeler (JIRA)


[ 
https://issues.apache.org/jira/browse/SLING-7934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16686598#comment-16686598
 ] 

Carsten Ziegeler commented on SLING-7934:
-

Thanks, that helps. So I have a stupid proposal but maybe it triggers something 
better :) 
What about adding a getJSONType(String key) method to ValueMap and it will 
return the correct type to be used as a json property (like long, boolean, 
String)?

> Add the ability for a resource to adapt to a JSONObject
> ---
>
> Key: SLING-7934
> URL: https://issues.apache.org/jira/browse/SLING-7934
> Project: Sling
>  Issue Type: Improvement
>Reporter: Jason E Bailey
>Assignee: Jason E Bailey
>Priority: Major
>
> There are multiple implementations all doing the same process of converting a 
> resource to a JSONObject. If it's that common we should just add the ability 
> to adapt the resource and centralize the implementation so that it's 
> consistent.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SLING-7934) Add the ability for a resource to adapt to a JSONObject

2018-11-14 Thread Jason E Bailey (JIRA)


[ 
https://issues.apache.org/jira/browse/SLING-7934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16686583#comment-16686583
 ] 

Jason E Bailey commented on SLING-7934:
---

So here is a real world scenario that I currently deal with.
 * I have form submissions that come in and get stored as resources
 * I then process those resources through a workflow.
 * One of the final steps of the workflow is to take the content of the 
resource as it is and send it as json object to an internal message queue.

With your input, which I really appreciate, I don't think the adaptTo solution 
would work. However I feel the current process of converting a resource to JSON 
is to cumbersome. We have an explicit set of possible value types that we work 
with in a map. I feel there should be a solution somewhere, maybe a utility, 
that takes a generic Map and converts it to JSON.

> Add the ability for a resource to adapt to a JSONObject
> ---
>
> Key: SLING-7934
> URL: https://issues.apache.org/jira/browse/SLING-7934
> Project: Sling
>  Issue Type: Improvement
>Reporter: Jason E Bailey
>Assignee: Jason E Bailey
>Priority: Major
>
> There are multiple implementations all doing the same process of converting a 
> resource to a JSONObject. If it's that common we should just add the ability 
> to adapt the resource and centralize the implementation so that it's 
> consistent.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SLING-7934) Add the ability for a resource to adapt to a JSONObject

2018-11-12 Thread Carsten Ziegeler (JIRA)


[ 
https://issues.apache.org/jira/browse/SLING-7934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16684782#comment-16684782
 ] 

Carsten Ziegeler commented on SLING-7934:
-

True, but if you want to stream json out, creating a JsonObject in between is 
not really efficient, direct streaming would be better and the 
JsonObjectCreator is for the general case whereas if you have a specific case 
you know what you have and into what you want to convert it.
Again, I'm not potentially trying to kill this proposal, I'm trying to 
understand where/how this could help.
If JsonObject would be mutable, it would imho be a different story

> Add the ability for a resource to adapt to a JSONObject
> ---
>
> Key: SLING-7934
> URL: https://issues.apache.org/jira/browse/SLING-7934
> Project: Sling
>  Issue Type: Improvement
>Reporter: Jason E Bailey
>Assignee: Jason E Bailey
>Priority: Major
>
> There are multiple implementations all doing the same process of converting a 
> resource to a JSONObject. If it's that common we should just add the ability 
> to adapt the resource and centralize the implementation so that it's 
> consistent.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SLING-7934) Add the ability for a resource to adapt to a JSONObject

2018-11-12 Thread Jason E Bailey (JIRA)


[ 
https://issues.apache.org/jira/browse/SLING-7934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16684342#comment-16684342
 ] 

Jason E Bailey commented on SLING-7934:
---

I'm not sure what you're definition of easily done is in this case. There's a 
whole class, org.apache.sling.servlets.get.impl.util.JsonObjectCreator, which 
was created to convert a resource to a JsonObject via a ValueMap and that is an 
internal class. If someone would like to do the same thing they would need to 
copy this class over or write their own.

> Add the ability for a resource to adapt to a JSONObject
> ---
>
> Key: SLING-7934
> URL: https://issues.apache.org/jira/browse/SLING-7934
> Project: Sling
>  Issue Type: Improvement
>Reporter: Jason E Bailey
>Assignee: Jason E Bailey
>Priority: Major
>
> There are multiple implementations all doing the same process of converting a 
> resource to a JSONObject. If it's that common we should just add the ability 
> to adapt the resource and centralize the implementation so that it's 
> consistent.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SLING-7934) Add the ability for a resource to adapt to a JSONObject

2018-11-11 Thread Carsten Ziegeler (JIRA)


[ 
https://issues.apache.org/jira/browse/SLING-7934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16682809#comment-16682809
 ] 

Carsten Ziegeler commented on SLING-7934:
-

I'm still a little bit struggling with how to use this. JsonObject is 
immutable, so any client code getting this JsonObject that wants to stream a 
different JSON structure than the one represented by the returned JsonObject 
needs to do quiet some complex manipulation to get a new JsonObject with the 
correct structure out of it. It's not possible to remove or add a property 
without creating a new JsonObject.
In that case creating a JsonObject out of a resource can as easily be done by 
adapting the resource to a value map, although value map does not support a 
hierarchy only a flat list of properties. Maybe that's the issue to fix?

> Add the ability for a resource to adapt to a JSONObject
> ---
>
> Key: SLING-7934
> URL: https://issues.apache.org/jira/browse/SLING-7934
> Project: Sling
>  Issue Type: Improvement
>Reporter: Jason E Bailey
>Assignee: Jason E Bailey
>Priority: Major
>
> There are multiple implementations all doing the same process of converting a 
> resource to a JSONObject. If it's that common we should just add the ability 
> to adapt the resource and centralize the implementation so that it's 
> consistent.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SLING-7934) Add the ability for a resource to adapt to a JSONObject

2018-10-08 Thread Jason E Bailey (JIRA)


[ 
https://issues.apache.org/jira/browse/SLING-7934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16642282#comment-16642282
 ] 

Jason E Bailey commented on SLING-7934:
---

[~karlpauls] I'm honestly fine with either of those suggestions, however I'm 
not sure of the validity of that argument since it would be valid with any use 
of adaptTo which is used throughout the framework

> Add the ability for a resource to adapt to a JSONObject
> ---
>
> Key: SLING-7934
> URL: https://issues.apache.org/jira/browse/SLING-7934
> Project: Sling
>  Issue Type: Improvement
>Reporter: Jason E Bailey
>Priority: Major
>
> There are multiple implementations all doing the same process of converting a 
> resource to a JSONObject. If it's that common we should just add the ability 
> to adapt the resource and centralize the implementation so that it's 
> consistent.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SLING-7934) Add the ability for a resource to adapt to a JSONObject

2018-09-28 Thread Karl Pauls (JIRA)


[ 
https://issues.apache.org/jira/browse/SLING-7934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16631895#comment-16631895
 ] 

Karl Pauls commented on SLING-7934:
---

I'm not sure that I like this idea. If we really would want something like 
this, why not make it a library or failing that, a service? Using adaptTo will 
make for some unpleasant (because hard to detect) coupling to the adaptTo 
provider...

> Add the ability for a resource to adapt to a JSONObject
> ---
>
> Key: SLING-7934
> URL: https://issues.apache.org/jira/browse/SLING-7934
> Project: Sling
>  Issue Type: Improvement
>Reporter: Jason E Bailey
>Priority: Major
>
> There are multiple implementations all doing the same process of converting a 
> resource to a JSONObject. If it's that common we should just add the ability 
> to adapt the resource and centralize the implementation so that it's 
> consistent.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SLING-7934) Add the ability for a resource to adapt to a JSONObject

2018-09-28 Thread Carsten Ziegeler (JIRA)


[ 
https://issues.apache.org/jira/browse/SLING-7934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16631872#comment-16631872
 ] 

Carsten Ziegeler commented on SLING-7934:
-

Ok, thanks - I'm not saying it should do this, but yes it would be cool. But I 
assume that others will ask the same questions once they can use it :)

> Add the ability for a resource to adapt to a JSONObject
> ---
>
> Key: SLING-7934
> URL: https://issues.apache.org/jira/browse/SLING-7934
> Project: Sling
>  Issue Type: Improvement
>Reporter: Jason E Bailey
>Priority: Major
>
> There are multiple implementations all doing the same process of converting a 
> resource to a JSONObject. If it's that common we should just add the ability 
> to adapt the resource and centralize the implementation so that it's 
> consistent.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SLING-7934) Add the ability for a resource to adapt to a JSONObject

2018-09-28 Thread Jason E Bailey (JIRA)


[ 
https://issues.apache.org/jira/browse/SLING-7934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16631869#comment-16631869
 ] 

Jason E Bailey commented on SLING-7934:
---

The JSONObjectCreator in the Default GET servlets is a private class and not 
exposed by the Bundle. I only see the use of JSON when you are sending data, 
either as a response to a query or you are posting the data elsewhere. The use 
case of Posting the content of the resource is something that I have done 
several times downstream.

The answer to your follow up questions is No. My thoughts was that this was a 
utility to assist in creating a JSON from a resource and not tied back to the 
underlying resource provider. Although that would be cool.

> Add the ability for a resource to adapt to a JSONObject
> ---
>
> Key: SLING-7934
> URL: https://issues.apache.org/jira/browse/SLING-7934
> Project: Sling
>  Issue Type: Improvement
>Reporter: Jason E Bailey
>Priority: Major
>
> There are multiple implementations all doing the same process of converting a 
> resource to a JSONObject. If it's that common we should just add the ability 
> to adapt the resource and centralize the implementation so that it's 
> consistent.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SLING-7934) Add the ability for a resource to adapt to a JSONObject

2018-09-27 Thread Carsten Ziegeler (JIRA)


[ 
https://issues.apache.org/jira/browse/SLING-7934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16629891#comment-16629891
 ] 

Carsten Ziegeler commented on SLING-7934:
-

Some more questions:
- is the same JSONObject instance returned for each invocation on the same 
resource object?
- is the JSONObject immutable? 
- If the JSONObject is mutable, is it intended to write changes back to the 
storage (similar to ModifiableValueMap) ?

> Add the ability for a resource to adapt to a JSONObject
> ---
>
> Key: SLING-7934
> URL: https://issues.apache.org/jira/browse/SLING-7934
> Project: Sling
>  Issue Type: Improvement
>Reporter: Jason E Bailey
>Priority: Major
>
> There are multiple implementations all doing the same process of converting a 
> resource to a JSONObject. If it's that common we should just add the ability 
> to adapt the resource and centralize the implementation so that it's 
> consistent.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SLING-7934) Add the ability for a resource to adapt to a JSONObject

2018-09-17 Thread Carsten Ziegeler (JIRA)


[ 
https://issues.apache.org/jira/browse/SLING-7934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16617767#comment-16617767
 ] 

Carsten Ziegeler commented on SLING-7934:
-

I'm not totally against this, but I would assume that either the default JSON 
is good enough and then the json servlet does the trick to serve the JSON - and 
in the other cases a special JSON needs to be generated which is not the 
default one.
Are you intending that for the latter case, there is a more specific adaptTo 
implementation?

> Add the ability for a resource to adapt to a JSONObject
> ---
>
> Key: SLING-7934
> URL: https://issues.apache.org/jira/browse/SLING-7934
> Project: Sling
>  Issue Type: Improvement
>Reporter: Jason E Bailey
>Priority: Major
>
> There are multiple implementations all doing the same process of converting a 
> resource to a JSONObject. If it's that common we should just add the ability 
> to adapt the resource and centralize the implementation so that it's 
> consistent.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SLING-7934) Add the ability for a resource to adapt to a JSONObject

2018-09-17 Thread Jason E Bailey (JIRA)


[ 
https://issues.apache.org/jira/browse/SLING-7934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16617713#comment-16617713
 ] 

Jason E Bailey commented on SLING-7934:
---

[~cziegeler] 
{code:java}
java.javax.JsonObject json = resource.adaptTo(JsonObject .class);{code}
Internally it would use the javax.json.JsonObjectBuilder and create a 
JsonObject based on that Resource.

 

 

> Add the ability for a resource to adapt to a JSONObject
> ---
>
> Key: SLING-7934
> URL: https://issues.apache.org/jira/browse/SLING-7934
> Project: Sling
>  Issue Type: Improvement
>Reporter: Jason E Bailey
>Priority: Major
>
> There are multiple implementations all doing the same process of converting a 
> resource to a JSONObject. If it's that common we should just add the ability 
> to adapt the resource and centralize the implementation so that it's 
> consistent.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SLING-7934) Add the ability for a resource to adapt to a JSONObject

2018-09-17 Thread Carsten Ziegeler (JIRA)


[ 
https://issues.apache.org/jira/browse/SLING-7934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16617683#comment-16617683
 ] 

Carsten Ziegeler commented on SLING-7934:
-

Before doing it, can you elaborate on what exactly it would do ? :)

> Add the ability for a resource to adapt to a JSONObject
> ---
>
> Key: SLING-7934
> URL: https://issues.apache.org/jira/browse/SLING-7934
> Project: Sling
>  Issue Type: Improvement
>Reporter: Jason E Bailey
>Priority: Major
>
> There are multiple implementations all doing the same process of converting a 
> resource to a JSONObject. If it's that common we should just add the ability 
> to adapt the resource and centralize the implementation so that it's 
> consistent.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (SLING-7934) Add the ability for a resource to adapt to a JSONObject

2018-09-17 Thread Jason E Bailey (JIRA)


[ 
https://issues.apache.org/jira/browse/SLING-7934?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=16617614#comment-16617614
 ] 

Jason E Bailey commented on SLING-7934:
---

I have no issue doing this, I am uncertain which bundle it should be 
implemented in.

> Add the ability for a resource to adapt to a JSONObject
> ---
>
> Key: SLING-7934
> URL: https://issues.apache.org/jira/browse/SLING-7934
> Project: Sling
>  Issue Type: Improvement
>Reporter: Jason E Bailey
>Priority: Major
>
> There are multiple implementations all doing the same process of converting a 
> resource to a JSONObject. If it's that common we should just add the ability 
> to adapt the resource and centralize the implementation so that it's 
> consistent.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)