Hi Udara,
I have tried with the online JSON POJO converter [1] with the grouping
json. I get the following bean class for ServiceGroupDefinition. Currently
we have used list for cartridges, subGroups and staupOrders. I think this
should be change to String array. WDYT ?
public class ServiceGroupDefinition
{
private Dependencies dependencies;
private String name;
private String[] subGroups;
private String[] cartridges;
public Dependencies getDependencies ()
{
return dependencies;
}
public void setDependencies (Dependencies dependencies)
{
this.dependencies = dependencies;
}
public String getName ()
{
return name;
}
public void setName (String name)
{
this.name = name;
}
public String[] getSubGroups ()
{
return subGroups;
}
public void setSubGroups (String[] subGroups)
{
this.subGroups = subGroups;
}
public String[] getCartridges ()
{
return cartridges;
}
public void setCartridges (String[] cartridges)
{
this.cartridges = cartridges;
}
}
public class Dependencies
{
private String terminationBehaviour;
private String[] startupOrders;
public String getTerminationBehaviour ()
{
return terminationBehaviour;
}
public void setTerminationBehaviour (String terminationBehaviour)
{
this.terminationBehaviour = terminationBehaviour;
}
public String[] getStartupOrders ()
{
return startupOrders;
}
public void setStartupOrders (String[] startupOrders)
{
this.startupOrders = startupOrders;
}
}
[1] http://pojo.sodhanalibrary.com/
Thanks !
On Wed, Nov 5, 2014 at 7:55 PM, Manula Chathurika Thantriwatte <
[email protected]> wrote:
> Hi Udara,
>
> I think the POJO conversion didn't happen correctly. That's why it didn't
> deserialize correctly.
>
> On Wed, Nov 5, 2014 at 7:41 PM, Udara Liyanage <[email protected]> wrote:
>
>> Hi,
>>
>> You can find it [1]. Please note that other bean classes have public
>> variables which are set when converting to a pojo. This bean as private
>> variables and public getters and setters.
>>
>> [1]
>> https://github.com/apache/stratos/blob/docker-grouping-merge/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/grouping/definitions/ServiceGroupDefinition.java
>>
>> On Wed, Nov 5, 2014 at 7:34 PM, Nirmal Fernando <[email protected]>
>> wrote:
>>
>>> Can you point to the relevant rest endpoint bean ?
>>>
>>> On Wed, Nov 5, 2014 at 2:52 PM, Udara Liyanage <[email protected]> wrote:
>>>
>>>> Hi Nirmal,
>>>>
>>>> But it works in get deployment policy endpoint, so it can not be a
>>>> limitation ?
>>>>
>>>> curl -X GET -H "Content-Type: application/json" -d @'app-php-only.json'
>>>> -k -u admin:admin
>>>> https://localhost:9443/stratos/admin/policy/deployment/economyDeploymentPolicy
>>>> | python -m json.tool
>>>> % Total % Received % Xferd Average Speed Time Time Time
>>>> Current
>>>> Dload Upload Total Spent Left
>>>> Speed
>>>> 100 908 0 353 100 555 5364 8434 --:--:-- --:--:--
>>>> --:--:-- 8538
>>>> {
>>>> "deploymentPolicy": {
>>>> "id": "economyDeploymentPolicy",
>>>> "partitionGroup": [
>>>> {
>>>> "id": "ec2",
>>>> *"partition": [*
>>>> * {*
>>>> * "id": "AWSEC2AsiaPacificPartition1",*
>>>> * "isPublic": false,*
>>>> * "partitionMax": 3,*
>>>> * "partitionMin": 1,*
>>>> * "property": [*
>>>> * {*
>>>> * "name": "region",*
>>>> * "value": "ap-southeast-1"*
>>>> * },*
>>>> * {*
>>>> * "name": "zone",*
>>>> * "value": "ap-southeast-1a"*
>>>> * }*
>>>> * ],*
>>>> * "provider": "ec2"*
>>>> * }*
>>>> * ],*
>>>> "partitionAlgo": "one-after-another"
>>>> }
>>>> ],
>>>> "public": false
>>>> }
>>>> }
>>>>
>>>>
>>>> On Wed, Nov 5, 2014 at 7:21 PM, Udara Liyanage <[email protected]> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> When I add the name of the variable to the cxf-servlet.xml as
>>>>> serializeAsArray,
>>>>> now cartridges are shown as arrays.
>>>>> <value>cartridges</value>
>>>>>
>>>>> But we can't specify it for each variable.
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Wed, Nov 5, 2014 at 6:35 PM, Udara Liyanage <[email protected]> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> When I execute the GET serviceGroup Stratos endpoint I get the
>>>>>> folowing output in two different groups. Please note cartridges text in
>>>>>> bold. When there are only one cartridge, it shows as a String (output1),
>>>>>> when there are multiple cartridges it is shown as an array (output2).
>>>>>>
>>>>>> But when I convert the object to a json text, it shows as arrays even
>>>>>> when there are single cartridge.
>>>>>>
>>>>>> The issue happens when the object is sent in response as below
>>>>>>
>>>>>> return Response.ok().entity(serviceGroupDefinition).build();
>>>>>>
>>>>>>
>>>>>> In the code carridges is set as a list.
>>>>>>
>>>>>>
>>>>>> 1. List<String> cartridgesDef = new ArrayList<String>(Arrays.
>>>>>> asList(cartridges));
>>>>>> 2. servicegroupDef.setCartridges(cartridgesDef);
>>>>>>
>>>>>>
>>>>>> [1] suggested to set serializeAsArray as true in cxf-servlet.xml.xml,
>>>>>> I tried doing it too. But same result.
>>>>>>
>>>>>> What is the reason for this?
>>>>>>
>>>>>>
>>>>>> output [1]
>>>>>>
>>>>>> {
>>>>>> "serviceGroup": [
>>>>>> {
>>>>>> * "cartridges": "tomcat",*
>>>>>> "dependencies": {
>>>>>> "startupOrders": "group.group1,cartridge.tomcat",
>>>>>> "terminationBehaviour": "terminate-dependents"
>>>>>> },
>>>>>> "name": "group5",
>>>>>> "subGroups": "group1"
>>>>>> }
>>>>>> ]
>>>>>> }
>>>>>>
>>>>>> output [2]
>>>>>>
>>>>>> {
>>>>>> "serviceGroup": {
>>>>>> "cartridges": *[*
>>>>>> * "tomcat",*
>>>>>> * "php"*
>>>>>> * ],*
>>>>>> "dependencies": {
>>>>>> "startupOrders": "group.group1,cartridge.tomcat",
>>>>>> "terminationBehaviour": "terminate-dependents"
>>>>>> },
>>>>>> "name": "group6",
>>>>>> "subGroups": "group2"
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> [1]
>>>>>> http://stackoverflow.com/questions/18918091/when-a-list-has-only-one-element-cxf-return-the-object-instead-a-js-array
>>>>>> --
>>>>>>
>>>>>> Udara Liyanage
>>>>>> Software Engineer
>>>>>> WSO2, Inc.: http://wso2.com
>>>>>> lean. enterprise. middleware
>>>>>>
>>>>>> web: http://udaraliyanage.wordpress.com
>>>>>> phone: +94 71 443 6897
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> Udara Liyanage
>>>>> Software Engineer
>>>>> WSO2, Inc.: http://wso2.com
>>>>> lean. enterprise. middleware
>>>>>
>>>>> web: http://udaraliyanage.wordpress.com
>>>>> phone: +94 71 443 6897
>>>>>
>>>>
>>>>
>>>>
>>>> --
>>>>
>>>> Udara Liyanage
>>>> Software Engineer
>>>> WSO2, Inc.: http://wso2.com
>>>> lean. enterprise. middleware
>>>>
>>>> web: http://udaraliyanage.wordpress.com
>>>> phone: +94 71 443 6897
>>>>
>>>
>>>
>>>
>>> --
>>> Best Regards,
>>> Nirmal
>>>
>>> Nirmal Fernando.
>>> PPMC Member & Committer of Apache Stratos,
>>> Senior Software Engineer, WSO2 Inc.
>>>
>>> Blog: http://nirmalfdo.blogspot.com/
>>>
>>
>>
>>
>> --
>>
>> Udara Liyanage
>> Software Engineer
>> WSO2, Inc.: http://wso2.com
>> lean. enterprise. middleware
>>
>> web: http://udaraliyanage.wordpress.com
>> phone: +94 71 443 6897
>>
>
>
>
> --
> Regards,
> Manula Chathurika Thantriwatte
> Software Engineer
> WSO2 Inc. : http://wso2.com
> lean . enterprise . middleware
>
> email : [email protected] / [email protected]
> phone : +94 772492511
> blog : http://manulachathurika.blogspot.com/
>
>
>
>
--
Regards,
Manula Chathurika Thantriwatte
Software Engineer
WSO2 Inc. : http://wso2.com
lean . enterprise . middleware
email : [email protected] / [email protected]
phone : +94 772492511
blog : http://manulachathurika.blogspot.com/