#set ($layout="json.vm")
#set ($dummy = $dbtool)
#set ($res=${response.setContentType("application/json")})
#if($params.key)
#set ($pr=$profiles)
#set ($res=$pr.load($params.key))
#set ($pros=[ $pr ])
#{else}[
#set ($pros=$profiles.fetchAll())
#end
#set ($count=$pros.size())
#foreach ($pr in $sorter.sort($pros,"name"))
#if ($count!=$velocityCount)
#set ($sep=",")
#else
#set ($sep="")
#end
#set($package_lists=$pr.getPackageLists())
{ "id": $pr.id, "name": "$pr.name", "alternateProfile": "$!pr.alternateProfile", "owner": "$!pr.owner", "description": "$!pr.description", "configExtras": "$!pr.configExtras", "packageLists": [#foreach($pl in $package_lists) "$pl.name"#if ($velocityCount!=$package_lists.size()),#{end}#{end} ], "approved": $pr.checkApprovals() }$!sep
#end
#if(!$params.key)
]
#end
