private Offering getOfferingFromJSON ( JSONObject obj ) throws IOException { JSONArray infrastructures = ( JSONArray ) obj . get ( "infrastructures" ) ; String name = ( String ) obj . get ( "name" ) ; Offering offering = null ; if ( infrastructures == null || infrastructures . size ( ) == 0 ) { String providerName = Offering . sanitizeName ( name ) ; offering = this . parseOffering ( providerName , providerName , obj ) ; } else { for ( Object element : infrastructures ) { JSONObject infrastructure = ( JSONObject ) element ; String continent = "" ; String country = "" ; String fullName = name ; if ( infrastructure . containsKey ( "continent" ) ) { continent = infrastructure . get ( "continent" ) . toString ( ) ; if ( ! continent . isEmpty ( ) ) { continent = continentFullName . get ( continent ) ; fullName = fullName + "." + continent ; } } if ( infrastructure . containsKey ( "country" ) ) { country = infrastructure . get ( "country" ) . toString ( ) ; if ( ! country . isEmpty ( ) ) fullName = fullName + "." + country ; } String providerName = Offering . sanitizeName ( name ) ; String offeringName = Offering . sanitizeName ( fullName ) ; offering = this . parseOffering ( providerName , offeringName , obj ) ; if ( ! continent . isEmpty ( ) ) offering . addProperty ( "continent" , continent ) ; if ( ! country . isEmpty ( ) ) offering . addProperty ( "country" , country ) ; } } return offering ; }
Conversion from Paasify JSON model into TOSCA PaaS model