# Wiki source code of License JSON

Last modified by Jean Franco on 2022/07/30 13:08
Export
Office Formats
Export as PDF Export as ODT Export as RTF
Other Formats
Export as HTML

Hide last authors

author | version | line-number | content
--- | --- | --- | ---
| 1.1 | 1 | {{include reference="Licenses.Code.VelocityMacros"/}}
|  | 2 |
|  | 3 | {{velocity output="false"}}
|  | 4 | #macro (addPaidExtensionRow $extension $rows)
|  | 5 | #set ($license = $services.licensing.licensor.getLicenseForExtension($extension.id))
|  | 6 | ##
|  | 7 | ## Expiration Date
|  | 8 | ##
|  | 9 | #if (!$license || $license.expirationDate == 0)
|  | 10 | #set ($expDateStatus = 'danger')
|  | 11 | #set ($expDate = $services.localization.render('licensor.status.noLicenseAvailable'))
|  | 12 | #elseif ($license.expirationDate == $LONG_MAX_VALUE)
|  | 13 | #set ($expDateStatus = 'success')
|  | 14 | #set ($expDate = $services.localization.render('licensor.status.infinite'))
|  | 15 | #else
|  | 16 | #set ($expDateStatus = "#if ($license.expirationDate > $datetool.date.time)success#{else}danger#end")
|  | 17 | #set ($expDate = $datetool.format('dd/MM/yyyy', $license.expirationDate))
|  | 18 | #end
|  | 19 | #set ($expDate = "<span class=""text-$!expDateStatus"">$!escapetool.xml($expDate)</span>")
|  | 20 | ##
|  | 21 | ## Support
|  | 22 | ##
|  | 23 | #set ($support = $license.licensee.support)
|  | 24 | #if ("$!support" != '')
|  | 25 | #set ($translationKey = 'licensor.support.' + $support.toLowerCase())
|  | 26 | #if ($services.localization.get($translationKey))
|  | 27 | #set ($support = $services.localization.render($translationKey))
|  | 28 | #else
|  | 29 | #set ($support = $stringtool.capitalize($support))
|  | 30 | #end
|  | 31 | #else
|  | 32 | #set ($support = $services.localization.render('licensor.support.unspecified'))
|  | 33 | #end
|  | 34 | ##
|  | 35 | ## User Limit
|  | 36 | ##
|  | 37 | #if (!$license || !$license.maxUserCount || $license.maxUserCount == $LONG_MAX_VALUE
|  | 38 | || ($license.maxUserCount == 0 && $license.expirationDate == 0))
|  | 39 | ## The default value for the maxUserCount field of a license is Long.MAX_VALUE so when we encounter this value
|  | 40 | ## we consider that the max user count was not specified.
|  | 41 | #set ($userLimitStatus = 'muted')
|  | 42 | #set ($userLimit = $services.localization.render('licensor.userLimit.unspecified'))
|  | 43 | #elseif ($license.maxUserCount < 0)
|  | 44 | #set ($userLimitStatus = 'success')
|  | 45 | #set ($userLimit = $services.localization.render('licensor.userLimit.unlimited'))
|  | 46 | #else
|  | 47 | #set ($userLimitStatus = "#if ($userCount <= $license.maxUserCount)success#{else}danger#end")
|  | 48 | #set ($userLimit = "$!userCount / $!license.maxUserCount")
|  | 49 | #end
|  | 50 | #set ($userLimit = "<span class=""text-$!userLimitStatus"">$!escapetool.xml($userLimit)</span>")
|  | 51 | ##
|  | 52 | ## Namespaces and Version
|  | 53 | ##
|  | 54 | #set ($namespaces = [])
|  | 55 | #foreach ($namespace in $extension.namespaces)
|  | 56 | #if ($namespace)
|  | 57 | #set ($wikiPrettyName = $services.wiki.getById($namespace.split(':')[1]).prettyName)
|  | 58 | #else
|  | 59 | ## Create a pretty name for the extensions installed at root level (Installed on Farm).
|  | 60 | #set ($wikiPrettyName = $services.localization.render('licensor.wiki.installedOnFarm'))
|  | 61 | #end
|  | 62 | #set ($discard = $namespaces.add($wikiPrettyName))
|  | 63 | #end
|  | 64 | ## SortTool is deprecated since 12.0.
|  | 65 | #if ($collectiontool)
|  | 66 | #set ($namespaces = $collectiontool.sort($namespaces))
|  | 67 | #else
|  | 68 | #set ($namespaces = $sorttool.sort($namespaces))
|  | 69 | #end
|  | 70 | ##
|  | 71 | ## Other
|  | 72 | ##
|  | 73 | #set ($queryString = $escapetool.url({
|  | 74 | 'instanceId': $services.instance.instanceId,
|  | 75 | 'featureId': $extension.id.id,
|  | 76 | 'extensionVersion': $extension.id.version,
|  | 77 | 'firstName': $ownerObj.getValue('firstName'),
|  | 78 | 'lastName': $ownerObj.getValue('lastName'),
|  | 79 | 'email': $ownerObj.getValue('email')
|  | 80 | }))
|  | 81 | #set ($documentationURL = "${storeAccessURL}?${queryString}")
|  | 82 | #set ($discard = $rows.add({
|  | 83 | 'doc_viewable': true,
|  | 84 | 'name': $extension.name,
|  | 85 | 'name_url': $documentationURL,
|  | 86 | 'version': $extension.id.version.toString(),
|  | 87 | 'status': $expDate,
|  | 88 | 'support': $support,
|  | 89 | 'userLimit': $userLimit,
|  | 90 | 'wiki': $stringtool.join($namespaces, ', '),
|  | 91 | 'actions': "#licenseActions($license $extension)"
|  | 92 | }))
|  | 93 | #end
|  | 94 | {{/velocity}}
|  | 95 |
|  | 96 | {{velocity wiki="false"}}
|  | 97 | #if ($xcontext.action == 'get')
|  | 98 | #set ($discard = $response.setContentType('application/json'))
|  | 99 | #end
|  | 100 | #if ($request.showAllPaidExtensions == 'true')
|  | 101 | #getPaidExtensions
|  | 102 | #set ($extensions = $paidExtensions)
|  | 103 | #else
|  | 104 | #getVisiblePaidExtensions
|  | 105 | #set ($extensions = $visiblePaidExtensions)
|  | 106 | #end
|  | 107 | #set ($rows = [])
|  | 108 | #foreach ($extension in $extensions)
|  | 109 | #addPaidExtensionRow($extension $rows)
|  | 110 | #end
|  | 111 | ## SortTool is deprecated since 12.0.
|  | 112 | #if ($collectiontool)
|  | 113 | #set ($rows = $collectiontool.sort($rows, 'name'))
|  | 114 | #else
|  | 115 | #set ($rows = $sorttool.sort($rows, 'name'))
|  | 116 | #end
|  | 117 | #set ($offset = $mathtool.sub($numbertool.toNumber($request.offset).intValue(), 1))
|  | 118 | #if ("$!offset" == '')
|  | 119 | #set ($offset = 0)
|  | 120 | #end
|  | 121 | #set ($offset = $mathtool.max($mathtool.min($offset, $mathtool.sub($rows.size(), 1)), 0))
|  | 122 | #set ($limit = $numbertool.toNumber($request.limit).intValue())
|  | 123 | #if ("$!limit" == '')
|  | 124 | #set ($limit = 10)
|  | 125 | #elseif ($limit <= 0)
|  | 126 | #set ($limit = $rows.size())
|  | 127 | #end
|  | 128 | #set ($limit = $mathtool.min($limit, $mathtool.sub($rows.size(), $offset)))
|  | 129 | $jsontool.serialize({
|  | 130 | 'reqNo': $request.reqNo,
|  | 131 | 'totalrows': $rows.size(),
|  | 132 | 'returnedrows': $limit,
|  | 133 | 'offset': $mathtool.add($offset, 1),
|  | 134 | 'rows': $rows.subList($offset, $mathtool.add($offset, $limit))
|  | 135 | })
|  | 136 | {{/velocity}}

# Applications

# Tips

If you're a new XWiki user, check out the Getting Started Guide.

Maila Networks
XWiki Debian 14.4.1